nidhi has asked for the wisdom of the Perl Monks concerning the following question:
I need to create a hash of keys for eg : Vlan8,Vlan12 (not Vlan1) and value containing : 8,12 respectively. Only those key-value pair gets stored which has an ip address given in the next 1 or more lines. I tried the following :interface Vlan1 no ip address no ip route-cache shutdown ! interface Vlan12 ip address 68.142.192.79 255.255.255.0 no ip route-cache shutdown ! interface Vlan8 ip address 68.142.192.79 255.255.255.0 no ip route-cache !
while(<IN>) { my ($key) = /^(interface Vlan[\d]*)/; next if $key =~ /^\s ip address \d*\.\d*\.\d*\.\d* \d*\.\d*\.\d*\.\d*/ +; # next if $key =~ /^\s*$/; my ($value) = /^interface Vlan([\d]*)/; $hash1{$key} = $value ; }
I dont' want Vlan1. plz. help!interface Vlan1 => 1 interface Vlan8 => 8 interface Vlan12 => 12
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: create key-value pair
by GrandFather (Saint) on Aug 28, 2007 at 21:30 UTC | |
|
Re: create key-value pair
by bruceb3 (Pilgrim) on Aug 28, 2007 at 21:39 UTC | |
|
Re: create key-value pair
by runrig (Abbot) on Aug 28, 2007 at 21:41 UTC | |
|
Re: create key-value pair
by Fletch (Bishop) on Aug 28, 2007 at 21:29 UTC | |
|
Re: create key-value pair
by McDarren (Abbot) on Aug 28, 2007 at 21:41 UTC | |
|
Re: create key-value pair
by brent.allsop (Acolyte) on Aug 29, 2007 at 03:01 UTC |