I want capture :interface mgmt0 ip address 10.33.81.52 255.255.240.0 interface fc1/1 switchport description Trunk switchport mode E channel-group 3 force no shutdown interface fc1/2 interface fc1/3 no shutdown interface fc1/4 no shutdown interface fc1/5 interface fc1/6 interface fc1/7 switchport description DMX02_FA4CA no shutdown interface fc1/8 no shutdown interface fc1/9 interface fc1/10 interface fc1/11 switchport description DMX02_FA7CA no shutdown interface fc1/12 no shutdown interface fc1/13 switchport mode SD switchport speed 1000 no shutdown interface fc1/14 interface fc1/15 no shutdown
So I nicked this codeinterface mgmt0 = interface fc1/1 = switchport description Trunk interface fc1/2 = interface fc1/3 = interface fc1/4 = interface fc1/5 = interface fc1/6 = interface fc1/7 =switchport description DMX02_FA4CA . . . .
Although the above code makes sense to me, but I didn't get any output!#! c:/perl/bin/prl.exe # use strict; my ($Rec,$pc_name); while (<DATA>) { $pc_name = $1, next if (/interface (\.)+$/); $Rec->{$pc_name}->{$1} = $2 if (/switchport description (\.+)$/); } for my $data (keys %{$Rec}) { print "$data \n"; for my $data2 (keys %{$Rec->{$data}}) { print "\t$data2 : $Rec->{$data}->{$data2}\n"; } }
In reply to RegEx Blues by blackadder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |