PERL look ahead and behind ...

I would like to search a router config file for "ip address $ip", once found, I want to grab the line just before that contains "interface $interfacetype"

basically saying, 10.3.127.9 is assigned to "Loopback1" given the below as an example.

interface Loopback1
ip address 10.3.127.9 255.255.255.255
!
interface FastEthernet0/0
ip address 10.3.126.9 255.255.255.248
ip access-group virus-security in
ip route-cache same-interface
no ip route-cache cef
no ip route-cache
no ip mroute-cache
ip policy route-map blockvirus445
duplex full
speed 100
ipx network 1090012A encapsulation SAP
bridge-group 1
bridge-group 1 input-lsap-list 200
!

Just remember the previous line in a variable.

while (<>) {
  print $prev, $_ if (m/10\.3\.127\.9/);
  $prev = $_;
}