in reply to Re: Another Challenge: Splitting data into chunks part2
in thread Another Challenge: Splitting data into chunks part2
I am sure I don't have to open the file twice. but not sure on how to do it. If I merge both loops then only one loop works!#! c:/perl/bin/perl.exe use strict; my ($Rec2, $pc_name); my ($hash,$key); open (LST,"c:/showtech".$ARGV[0].".txt") || die "$!\n"; while(<LST>) { $key = $1, next if (/interface port-channel (\d+)$/); $hash->{$key}->{$1} = $2 if (/switchport description To (\w+) ([\d +\.]+)/); } close LST; open (LST,"c:/showtech".$ARGV[0].".txt") || die "$!\n"; while(<LST>) { $pc_name = $1, next if (/(port-channel \d+)$/); $Rec2->{$pc_name}->{$1} = $2 if (m|(fc\d+/\d+)\s+\[(\w+)\]|); } for my $data (keys %{$Rec2}) { print "\n$data \n"; } for my $data (keys %{$hash}) { print "$data\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Another Challenge: Splitting data into chunks part2
by goldclaw (Scribe) on Sep 21, 2005 at 16:11 UTC |