my @v= keys %h;
die "Got extra Z: @v\n" if @v >1
####
DB<100> sub check { die "Got extra Z: @_\n" if @_ >1 }
DB<101> %h=(a=>1)
=> ("a", 1)
DB<102> check my @v= keys %h
=> ""
DB<103> %h=(a=>1,b=>2)
=> ("a", 1, "b", 2)
DB<104> check my @v= keys %h
Got extra Z: a b
##
##
DB<106> sub avoid (&;@) {
my $code=shift;
my $msg = $code->(@_);
die $msg if $msg;
}
DB<107> avoid { "Got extra Z: @_\n" if @_ >1 } my @v = keys %h;
Got extra Z: a b
DB<108> %h=(a=>1)
=> ("a", 1)
DB<109> avoid { "Got extra Z: @_\n" if @_ >1 } my @v = keys %h;
DB<110>
##
##
avoid { "Got extra Z: @_\n" if @_ >1 }
my @v = keys %h;
##
##
The declared variable is not introduced (is not visible) until after
the current statement. Thus,
my $x = $x;
can be used to initialize a new $x with the value of the old $x, and
the expression
my $x = 123 and $x == 123
is false unless the old $x happened to have the value 123.