use strict; use warnings; open(FH,"data"); foreach() { print $_; if ( $_ =~ m/^ip address/) {print $_;} }