On 12 January 2016 at 13:53, Chad Granum <[email protected]> wrote:
> $! and $@ are altered by many many things, adding { local ... } around all
> of them is a pain
As much as I agree, and as much as this is a "thing in all perl, so we
should expect this problem from every module"
If I was to offer a counter example, consider the effort of a `*.t`
file needing to preserve these things instead.
> ok(do_something_scary());
> is($!, 0, "expected $! val");
> is($@, undef, '$@ not changed');
vs
> my ( $error, $exception );
> ok(do {
> local $@;
> local $!;
> my $ret = do_something_scary());
> ( $error, $exception ) = ($!, $@);
> $ret
> });
> is($error, 0, "expected $! val");
> is($exception, undef, '$@ not changed);
I'm not sure I'd consider the second of these an "improvement".
--
Kent
KENTNL - https://metacpan.org/author/KENTNL