chrisayres11 has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I am going some Cisco show output parsing and print $_ unless is doing something weird (or at least weird to me)
$_ = PID: , VID: 255, SN: AGM163923J5
my line of perl isprint $_ unless /PID: ,/;
but the line still prints
if I use
print $_ unless /PID: /;
the unless works correctly and the line doesn't print (but this is no good to me as it matches lines I want). Why is the addition of "," stopping it from working. Interestingly Cisco IOS CLI is doing the same
"show inv |i PID: ," doesn't match the line
is it a regex thing ??
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Print unless behaving strangely
by johngg (Canon) on Jun 01, 2014 at 22:22 UTC | |
by LanX (Saint) on Jun 01, 2014 at 22:59 UTC | |
by chrisayres11 (Novice) on Jun 03, 2014 at 09:26 UTC | |
|
Re: Print unless behaving strangely
by Laurent_R (Canon) on Jun 01, 2014 at 22:08 UTC | |
|
Re: Print unless behaving strangely
by LanX (Saint) on Jun 01, 2014 at 21:29 UTC | |
by boftx (Deacon) on Jun 01, 2014 at 21:48 UTC | |
|
Re: Print unless behaving strangely
by chrisayres11 (Novice) on Jun 03, 2014 at 10:32 UTC |