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 }