You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Conditional operator (ternary operator) can be localized effectively providing conditional local
our ($a, $b) = (1, 2);
{
local (@ARGV ? $a : $b) = ;
say "$a-$b";
}
{
($ARGV ? local $a : local $b) = 4;
say "$a-$b";
}
# Output (without @ARGV):
1-4
1-4
# Output (with ARGV):
4-2
4-2
my vs local consistency
{
our $a = 1;
{ $a = local $a = 2; $a++; say $a
say $a;
}
# Output:
3
1
{
our $a = 1;
{ $a = my $a = 2; $a++; say $a
say $a;
}
# Output:
3
2
Nested HEREDOC
say <<"FOO";
STR: ${ \ <<'FOO' };
fofo
FOO
FOO
# Output:
Can't find string terminator "FOO" anywhere before EOF at /home/brano/a.pl line 12.
Interpolated END
say ${
__END__
}
# Outputs:
Global symbol "$__END__" requires explicit package name (did you forget to declare "my $__END__"?) at /home/brano/a.pl line 14.
say ${
\$
__END__
}
# Outputs:
Missing right curly or square bracket at ...
my $__END__ = 'foo';
say ${
\$
__END__
}
# Outputs:
foo
sub __END__ { 'foo' }
say ${
\
__END__
}
# Outputs:
Missing right curly or square bracket at ...
my sub __END__ { 'foo' }
say ${
\
__END__
}
# Outputs:
foo