Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 romping around the Monastery: (21)
As of 2014-10-30 15:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (208 votes), past polls