in reply to Filter File that have certain word

It depends. Do you enter the whole contents of the file at once or line/record by line/record?
sub check_and_insert_into_database { my $filename = shift; open my $handle,"<",$filename or die "Can't open $filename: $!"; local $/; # read whole file instead of line-by-line my $contents = <$handle>; return if ($contents =~ /CLEAR/); # insert $contents into database }
update: see also perlretut and perlre, perlvar (for the $/ variable) and perlfaq7 and perlsub (for info on local() )