Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
static variable be undef if throw when initialize static variable.
use strict;
use warnings;
use utf8;
use feature qw/state/;
use Try::Tiny;
sub yyy {
state $f = 0;
die "DIE!!" unless $f++;
return $f;
}
sub xxx {
state $x = yyy();
return $x;
}
for (1..3) {
my $x;
try {
$x = xxx();
}
catch {
warn "catch: $_";
};
warn "x = $x";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.