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/; }
In reply to Re: create key-value pair
by runrig
in thread create key-value pair
by nidhi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |