#!/usr/bin/perl -w use strict; my $tmp = "/path/to/my.html"; my $pattern = qr/File Error/i; my $html; { local *INFILE; open( INFILE, $tmp ) or die "ack! $!"; -f INFILE && sysread( INFILE, $html, -s INFILE ); } die "$tmp: $pattern not found" unless $html =~ $pattern; # then continue...