in reply to create key-value pair
ormy $key; while (<IN>) { chomp; if ( my $status = /^interface Vlan/.../^!/ ) { $key = $_ if $status == 1; if ( /^\s*ip address (?:[\d.]+)/ ) { my ($value) = $key =~ /(\d+)/; $hash{$key} = $value; } } }
my $key; while (<IN>) { if ( /^(interface Vlan(\d+))/ ) { $key = $1; $hash{$1} = $2; } delete $hash{$key} if /no ip address/; }
|
|---|