Consider this example.
use strict; use warnings; use Fatal qw(:void open); # set $! to some random number; we just want to see # if it is modified $! = 42; print "$!\n"; open my $f, '<no_such_file' or die "Can't open no_such_file: $!";
The output is as follows.
Illegal byte sequence Can't open no_such_file: Illegal byte sequence at t.pl line 10.
$! doesn't seem to get modified. Taking a look at Fatal.pm, one sees the following at about line 121:
local(\$", \$!) = (', ', 0);
$" and $! are localized in the replacement subroutine, open in this example. Removing above line, and running the example again yields the following.
Illegal byte sequence Can't open no_such_file: No such file or directory at t.pl line 10.
This seems to be the desired outcome.
I don't use Fatal, so I can't tell if the localized $! is a bug or a feature.
In reply to Re: use Fatal ':void' vs. $!
by rblasch
in thread use Fatal ':void' vs. $!
by useruser
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |