my $lflag = ( -l 'foo' ); # check before opening $lflag or open my $fh, ">>foo" or ErrorHandler( $?, $! ); $lflag = ( -l 'foo' ); # and again after opening unless( $lflag } { # process file } $lflag or close $fh;