blackadder has asked for the wisdom of the Perl Monks concerning the following question:
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"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: RegEx Blues
by Fletch (Bishop) on Sep 22, 2005 at 17:47 UTC | |
by blackadder (Hermit) on Sep 23, 2005 at 08:09 UTC | |
|
Re: RegEx Blues
by diotalevi (Canon) on Sep 22, 2005 at 17:54 UTC | |
by blackadder (Hermit) on Sep 23, 2005 at 08:16 UTC | |
|
Re: RegEx Blues
by ikegami (Patriarch) on Sep 22, 2005 at 17:59 UTC | |
|
Re: RegEx Blues
by radiantmatrix (Parson) on Sep 22, 2005 at 19:12 UTC | |
|
Re: RegEx Blues
by Hue-Bond (Priest) on Sep 22, 2005 at 18:11 UTC |