#!/usr/bin/perl -w use strict; my $data = join '', ; if($data =~ s|(?=^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\nOS Type: unknown$)|\n|gm) { print "yes, it worked!"; } #print $data; exit(1); __DATA__ 10.1.1.1 bogus info 10.1.1.2 this could be anything 10.1.1.3 OS Type: unknown 10.1.1.4 filler information 10.1.1.5 OS Type: unknown #### perl -e "$q = qq(the brown dog\n is hailing a cab); if (($q=~m/\n(.*)/mg) && ($1 eq q( is hailing a cab))) { print qq(\n$1;)} else {print 'no luck buddy.';}"