in reply to matching patterns

I said it in the CB already:

Never use an unguarded assignment after a regex match. Always do
die "No data found" unless /...(...)/; my $value = $1;/
or do
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
    Thanks for the help.. didn't get it in the CB... now it does the trick