Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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]


~

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://259514]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2017-02-22 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (323 votes). Check out past polls.