in reply to $/ is playing havoc with my script.
"----switchname----" and the part you actually want to match are on different lines; thus, reading the file one line at a time, you can't match what you want the regex as you've shown. Also, your PortChannel_Num regex doesn't seem to work, since there is no line that consists solely of "port-channel (DIGITS)".
Here is a potential solution:
my %record; while (<FILE>) { if (/----switchname----/) { chomp($record{switchname} = <FILE>); } elsif (/^port-channel (\d+)/) { $record{channel} = $1; } }
|
|---|