Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #203466

Re: handling lists in perl

From mick crane <mick.crane@gmail.com>
Newsgroups linux.debian.user
Subject Re: handling lists in perl
Date 2018-12-19 06:10 +0100
Message-ID <x6Chj-4Q1-7@gated-at.bofh.it> (permalink)
References <x6nLj-4bW-5@gated-at.bofh.it> <x6nUZ-4fy-3@gated-at.bofh.it> <x6sUF-7sK-11@gated-at.bofh.it> <x6ydI-26h-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 2018-12-19 00:43, deloptes wrote:
> deloptes wrote:
> 
>> if ( @array =~ /$hash[$key]/) {
>> print "key $key with value " . $hash{$key} .
>> " is in the array of values\n";
>> }
> 
> I checked and it seems the right answer is
> 
> my %hash = ( 1=>8,2=>20,6=>100,15=>100 );
> my @array = (1, 21, 100, 8, 15, 22, 6, 12, 56);
> 
> foreach my $key (keys %hash) {
>         for (  @array ) {
>                 if ($_ eq $hash{$key} ) {
>                         print "key $key with value " . $hash{$key} .
>                                 " is in the array of values\n";
>                 }
>         }
> }

except there is only one 100 in @array it gets me along.
thanks and David too.

mick

-- 
Key ID    4BFEBB31

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

handling lists in perl mick crane <mick.crane@gmail.com> - 2018-12-18 14:40 +0100
  Re: handling lists in perl mick crane <mick.crane@gmail.com> - 2018-12-18 14:50 +0100
    Re: handling lists in perl deloptes <deloptes@gmail.com> - 2018-12-18 20:10 +0100
      Re: handling lists in perl deloptes <deloptes@gmail.com> - 2018-12-19 01:50 +0100
        Re: handling lists in perl mick crane <mick.crane@gmail.com> - 2018-12-19 05:40 +0100
        Re: handling lists in perl mick crane <mick.crane@gmail.com> - 2018-12-19 06:10 +0100
          Re: handling lists in perl deloptes <deloptes@gmail.com> - 2018-12-19 08:20 +0100
            Re: handling lists in perl mick crane <mick.crane@gmail.com> - 2018-12-19 09:30 +0100
              Re: handling lists in perl deloptes <deloptes@gmail.com> - 2018-12-19 09:40 +0100
                Re: handling lists in perl mick crane <mick.crane@gmail.com> - 2018-12-19 10:20 +0100
                Re: handling lists in perl mick crane <mick.crane@gmail.com> - 2018-12-19 10:30 +0100
                Re: handling lists in perl Andy Smith <andy@strugglers.net> - 2018-12-19 18:00 +0100
                Re: handling lists in perl deloptes <deloptes@gmail.com> - 2018-12-19 20:00 +0100
                Re: handling lists in perl David Wright <deblis@lionunicorn.co.uk> - 2018-12-19 21:50 +0100
                Re: handling lists in perl Greg Wooledge <wooledg@eeg.ccf.org> - 2018-12-19 22:10 +0100
    Re: handling lists in perl David Christensen <dpchrist@holgerdanske.com> - 2018-12-19 03:40 +0100
  Re: handling lists in perl Greg Wooledge <wooledg@eeg.ccf.org> - 2018-12-18 15:00 +0100

csiph-web