in reply to $/ is playing havoc with my script.

The ONLY thing $/ effects is reading from a filehandle. To change it (and then restore it) inside your while loop has no effect! Its value defines how <FH> operates.

"----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; } }

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart