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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.