in reply to Compare two index lists

# ALWAYS use strict :) use strict my @var2 =<INPUT> for my $var2 (@var2) { for (@var1) { # how is @var1 set??? print "match: $var1, $var2\n" if ($var2 =~ /$_/); } }

Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

Replies are listed 'Best First'.
Re: Re: Compare two index lists
by waswas-fng (Curate) on Aug 11, 2003 at 17:04 UTC
    What happens if for instance the word "lala" exists 4 times in each? the OP made it sound like that should not be printed.

    -Waswas
      Luckily the nature of the input file means that this should never happen! But...if it did... ideally the index should only be matched once. PS lines 9 and 10 should read
      chomp $var1; chomp $var2;
      i changed it to ease readers through the problem
Re: Re: Compare two index lists UPDATED
by pdotcdot (Acolyte) on Aug 11, 2003 at 17:54 UTC
    Hi there, Thanks for the suggestion, but it seems to still only bring back the first hit? -------------------THIS WAS BECAUSE MY FILES HAD HIDDEN CHARACTERS --------------SEE LATER NODE I too ALWAYS use strict :-), and thank the day it was made, as it saves me from my bad spelling!cheers again pc