nidhi has asked for the wisdom of the Perl Monks concerning the following question:
I did get help from perlmonks earlier but now I need to use this code in a tool called alterpoint which has some crazy ways of using perl.interface Port-channel31 description abc.xyz-conf no ip address load-interval 60 switchport switchport trunk encapsulation dot1q switchport trunk allowed vlan 15-17,30,35
where <IN> is the opened file. I need to get away with the IRS $/ as I dont think it works in alterpoint and also, I might have to do the pattern matching in the following manner :local $/ = "interface "; while(<IN>) { my ($key) = /description\s+ ([^\"][^\s]+)/x; next if $key =~ /^\s*$/; my ($value) = /switchport trunk allowed vlan\s*(.*)/; $hash2{$key} = $val ; }
or something...desperately need help!!my @lines = split(/^/, $config); # Iterate over the lines. foreach my $line (@lines) { if ($line =~ /description\s+ ([^\"][^\s]+)/x) { my ($key) = "$_"; next if ($line =~ /^\s*$/) } if ($line =~ /switchport trunk allowed vlan\s*(.*)/) { my ($value) = "$_"; } $hash1{$key} = $value ; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Another way to match multi-lines from config.
by johngg (Canon) on Sep 10, 2007 at 21:15 UTC | |
|
Re: Another way to match multi-lines from config.
by FunkyMonk (Bishop) on Sep 10, 2007 at 21:42 UTC | |
by nidhi (Acolyte) on Sep 10, 2007 at 23:09 UTC |