my $nofile; my $reason; my $tempfile = "$tempdir/$ENV{'REMOTE_ADDR'}"; my @tmpfile; if ( open( my $temp_fh, "<", $tempfile ) ) { @tmpfile = <$temp_fh>; close( $temp_fh ); # You don't need this, $temp_fh should be limited in scope } else { $nofile = 1; $reason = $!; # update: original typo == $@ }