in reply to Re^2: A regex question.
in thread A regex question.

... the negative match ...

It's important to understand that the negation is made on the result of the  /eth1\.\d{4}\@/gm match against the  $ethernet string. The match itself is actually successful! It's as if the
    if ($ethernet !~ /eth1\.\d{4}\@/gm) { ... }
statement had been written as
    if ( ! ($ethernet =~ /eth1\.\d{4}\@/gm)) { ... }
(note =~ vice !~). In fact, that's pretty much the way Perl sees the code:

c:\@Work\Perl\monks>perl -wMstrict -MO=Deparse,-p -le "my $ethernet=`ip addr`; if ($ethernet!~/eth1\.\d{4}\@/gm){ print qq{No vlans exist on device.\n}; exit; } " BEGIN { $^W = 1; } BEGIN { $/ = "\n"; $\ = "\n"; } use strict 'refs'; (my $ethernet = `ip addr`); unless (($ethernet =~ /eth1\.\d{4}\@/gm)) { print("No vlans exist on device.\n"); exit; } -e syntax OK

I had assumed /g was pointless on the if ...

Given what you were trying to do, it was pointless, but it was not without effect!


Give a man a fish:  <%-(-(-(-<