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

Re: checking the matches

by mwah (Hermit)
on May 22, 2008 at 09:58 UTC ( [id://687918]=note: print w/replies, xml ) Need Help??


in reply to checking the matches

Ikegami already provided a very compact solution using a hash. A more explicit (looped) variant would read like:

... for my $element (@array2) { my ($num, $txt) = split /#/, $element; # extract parts print "$txt = $num\n" if grep $num eq $_, @array1 # use text compa +rison and print txt part } ...

Regards

mwa

Replies are listed 'Best First'.
Re^2: checking the matches
by tweetymonk (Initiate) on May 22, 2008 at 10:47 UTC
    This is working absolutely fine, but is it possible to match only the numbers before the decimal point???

      Whats meant by "match the numbers before the decimal point"?

      One way could involve to 'int-ify' all comparisons:

      ... for my $element (@array2) { my ($num, $txt) = split /#/, $element; # extract parts print "$txt = ". int($num) ."\n" if grep int($num) eq int($_), @array1 # use text comparison and + print txt part } ...

      But I'm not entirely sure what you are trying to do.

      Regards

      mwa

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-26 04:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found