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 making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-07-04 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls