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 ; }
In reply to Another way to match multi-lines from config. by nidhi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |