#! c:/perl/bin/perl.exe use strict; #undef $/; #local $/; my $eof_tmp = $/; #$/=""; open (FILE,"$ARGV[0]") || die "\n$!: $ARGV[0]\n"; my $Rec = {}; while (my $Info = ) { undef $/; $Rec->{Switchname} = $1 if ($Info =~ /-+ show switchname -+\n(\w+)/sm); $/ = $eof_tmp; $Rec->{PortChannel_Num} = $1 if ($Info =~ /^(port-channel \d+)$/); } print "Switch Name: \t$Rec->{Switchname}\n"; print "Port Channel Number: \t$Rec->{PortChannel_Num}\n";