Created
October 28, 2013 10:14
-
-
Save karupanerura/7194399 to your computer and use it in GitHub Desktop.
static variable be undef if throw when initialize static variable.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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