Most of time, I do something like this:
open FH, ">file.txt" or die "Cann't open file: $!";
Does die
have to be used? If I want my script to continue (and simply ignore the error if the file cannot be opened), what should I do?
You might want to do something like
if(open my $fh, ">", "file.txt") {
# do stuff with file
close $fh;
}
else {
# do stuff without file
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With