Jose Malacara wrote:
>
> 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)/) ...
The periods in a regular expression match any character. You need to
escape them to match literal periods.
if ( $line =~ /(\Q$value\E)/ ) ...
> I only want to match the value exactly (192.168.1.1).
If you want to match exactly then you should use the 'eq' operator.
chomp $line;
if ( $line eq $value ) ...
> 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...)
>
> 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.
Show us what you tried.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]