open(FILE, "< $FILE") or die "ERROR: $!"; my $data; { local $/=undef; $data= } while ( $data =~ m{(.+?)}sg ) { my $rec = $1; if ( $rec =~ m{\d+/\d+} ) { push @cache, $rec; print "$rec"; } } close (FILE); #### $ test.pl 123456 123456 123456 1234/3456 123456 1234/3456 123456 123456