#!/usr/bin/perl -w # ytti@iki.fi use strict; my $hostname='foo'; while() { chop; if(/^hostname (.*)/) { $hostname=$1; } if(/^interface (.*)/) { my $accept=1; my $ip=0; my $int=$1; if ($int=~/en-tue-tätä/) { $accept=0; } while() { my $addess=0; last if(/^!/); if ($_=~/^ ip(?:v6)? address ([\d.:]+).*/) { $ip=$1; last; } } if($ip and $accept) { $int=~s/\//-/g; $int=~s/\./-/g; $int=~s/FastEthernet/fa/; $int=~s/GigabitEthernet/ge/; $int=~s/Loopback/lo/; print "$int." . lc($hostname) . " has address $ip\n"; } } }