#!/usr/bin/perl my $HN = `hostname`; my $hosts =`cat /etc/hosts`; if ( $hosts =~ /^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s+(${$HN})\s/g ) { print "$1\n"; print "$2\n"; } #### x.y.z.22 fredlocalhost x.y.z.23 fred-test-0 x.y.z.24 fred-test-1