blackadder has asked for the wisdom of the Perl Monks concerning the following question:
My question is: why is it if I comment lines 14 and 15, then lines 17 and 18 will work, and vise versa. But if I uncomment all of the four lines, then I get this error:#! c:/perl/bin/perl.exe # # use strict; use warnings; # $/="*\n"; my ($Rec,$pc_name); my ($hash,$key); while (<DATA>) { $pc_name = $1, next if (/port-channel (\d+)$/); #line 14 $Rec->{$pc_name}->{$1} = $2 if (m|(fc\d+/\d+)\s+\[(\w+)\]|); #line + 15 $key = $1, next if (/interface port-channel (\d+)$/); # line 17 $hash->{$key}->{$1} = $2 if (/switchport description To (\w+) ([\d +\.]+)/); #line 18 } for my $data (keys %{$Rec}) { print "\nPort-Channel $data : \n"; for my $data2 (keys %{$Rec->{$data}}) { print "\t$data2\n"; } } for my $data (keys %{$hash}) { print "\nInterface Port-Channel $data : \n"; for my $data2 (keys %{$hash->{$data}}) { print "\t$data2\n"; } } __DATA__ port-channel 1 Administrative channel mode is on Operational channel mode is on Last membership update succeeded First operational port is fc1/5 2 ports in total, 2 ports up Ports: fc2/5 [up] fc1/5 [up] * port-channel 3 Administrative channel mode is on Operational channel mode is on Last membership update succeeded First operational port is fc1/1 1 port in total, 1 port up Ports: fc1/1 [up] * interface port-channel 1 switchport trunk allowed vsan 1000 switchport trunk allowed vsan add 1050 switchport description To CCC219 10.33.81.56 switchport mode E interface port-channel 3 switchport trunk allowed vsan 1000 switchport trunk allowed vsan add 1010 switchport trunk allowed vsan add 1050 switchport trunk allowed vsan add 1900 switchport description To CCC215 10.33.81.52 switchport mode E
Grateful for all your help my fellow Monks.Use of uninitialized value in hash element at C:\Perl\test\mds1.pl <DATA> line 21. Use of uninitialized value in hash element at C:\Perl\test\mds1.pl <DATA> line 29. Port-Channel 1 : fc2/5 fc1/5 Port-Channel 3 : fc1/1 Interface Port-Channel : CCC215 CCC219 C:\Perl\test>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why is it "While Regex"ing,...Things do NOT seem to work!
by Roy Johnson (Monsignor) on Oct 10, 2005 at 17:06 UTC | |
|
Re: Why is it "While Regex"ing,...Things do NOT seem to work!
by pg (Canon) on Oct 10, 2005 at 17:16 UTC | |
|
Re: Why is it "While Regex"ing,...Things do NOT seem to work!
by pboin (Deacon) on Oct 10, 2005 at 17:17 UTC | |
|
Re: Why is it "While Regex"ing,...Things do NOT seem to work!
by Skeeve (Parson) on Oct 10, 2005 at 17:19 UTC | |
by blackadder (Hermit) on Oct 10, 2005 at 18:23 UTC | |
|
Re: Why is it "While Regex"ing,...Things do NOT seem to work!
by castaway (Parson) on Oct 11, 2005 at 09:16 UTC |