if($some_condition) { open my $fh, "<", "some_file" or last; # do something with $fh here if the open was successful # if the open fails we skip this part } do_something_else();