in reply to matching patterns
I said it in the CB already:
Never use an unguarded assignment after a regex match. Always door dodie "No data found" unless /...(...)/; my $value = $1;/my $value; if (/...(...)/) { $value = $1 };
In your case, this amount to:
... my $port = '<no port found>'; if ($line =~/(port=([0-9]+))/i) { $port= $2; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: matching patterns
by theroninwins (Friar) on Apr 11, 2006 at 07:07 UTC |