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
####
local $/ = "interface ";
while()
{
my ($key) = /description\s+ ([^\"][^\s]+)/x;
next if $key =~ /^\s*$/;
my ($value) = /switchport trunk allowed vlan\s*(.*)/;
$hash2{$key} = $val ;
}
####
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 ;
}