Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: comparing values between two arrays

by OM_Zen (Scribe)
on May 20, 2003 at 16:51 UTC ( #259514=note: print w/ replies, xml ) Need Help??


in reply to comparing values between two arrays

Hi ,

<BR><BR> my @numbers = ('25', '12', '32','56','45','21','65'); my @needed =('25','32','45','65'); my %hashofscalars = map{ $_ ,1}@needed; my $scalar; my @res_scalars; foreach ( @numbers) { if (exists $hashofscalars{$_}){ $scalar++;push(@res_scalars ,$_); }elsif($scalar%2 != 0){ push(@res_scalars,$_) } }; print "[@res_scalars]\n"; __END__ [25 12 32 45 21 65]


~


Comment on Re: comparing values between two arrays
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://259514]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2014-09-17 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (60 votes), past polls