#!/usr/bin/perl open FILE, "grepfile" or die "where is grepfile?"; while ( $blah = ) { $blah =~ /pl/; if ($1) { print $1 } else { print "no match" } } print $1; close FILE; exit;