One way to do it is to change what constitutes a "line end". In this case ! looks like a good character to choose as a line end character. Consider:
use warnings; use strict; $/ = '!'; while (<DATA>) { next unless /ip address (?:\d+\.){3}\d+/; next unless /interface (\w+(\d+))/; print "$1 -> $2\n"; } __DATA__ 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 !
Prints:
Vlan12 -> 2 Vlan8 -> 8
In reply to Re: create key-value pair
by GrandFather
in thread create key-value pair
by nidhi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |