in reply to Re: Comparing 1 list and 1 array
in thread Comparing 1 list and 1 array
is not a good way to look for an IP address in a line of text. First of all, it will match when you're searching for an IP that's a substring of the one contained in the text:print APPEND $line2 if $line2 =~ /$line1/;
Second, the periods in IP address strings will be interpreted as regular expression metacharacters:$line1 = '1.2.3.4'; $line2 = '111.2.3.44'; print "match\n" if $line2 =~ /$line1/;
$line1 = '1.2.3.4'; $line2 = '11223344'; print "match\n" if $line2 =~ /$line1/;
|
|---|