Can someone help me out here, please.
I have an if statement that is looping over a list of IP addresses:
192.168.1.1 192.168.1.2 192.168.1.3 ...192.168.1.10
$value="192.168.1.1"
if ($line =~ /($value)/) ...
I only want to match the value exactly (192.168.1.1). My problem is that I am matching all addresses containing that string (192.168.1.10, 192.168.1.11, 192.168.1.100, etc...)
In the case of an exact match why not just use string equality test? (don't forget to 'chomp' the line if you are getting it from a filehandle)
if ($line eq $value) ....
I know the trailing '$' anchors the match to the end of the line only, but I cannot seem to get it to work as I think my syntax is incorrect.
What trailing '$' you don't have one in the code you posted above...if you insist on the regex, it would go something like:
if ($line =~ /^($value)$/) ....
Which says match $value (and set it to $1) starting at the beginning of the string '^' and going until the end of the string '$'.
http://danconia.org
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]