Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: printing unitialized value of the 'do BLOCK'

by LanX (Saint)
on Dec 17, 2019 at 20:01 UTC ( [id://11110299]=note: print w/replies, xml ) Need Help??


in reply to Re^3: printing unitialized value of the 'do BLOCK'
in thread printing unitialized value of the 'do BLOCK'

> It's worth noting that if the two forms are equivalent, the latter is probably a lot less confusing when the output value is used.

It's also worth noting that B::Deparse can't always be trusted.

The clause of the if has the same scope like the inner block ( with if (CLAUSE) {BLOCK} )

DB<3> use strict; my $x=3; if (my $x =1) { print $x } 1 DB<4> use strict; if (my $x =1) { print $x }; print $x Global symbol "$x" requires explicit package name (did you forget to d +eclare "my $x"?) at (eval 13)[C:/Perl_524/lib/perl5db.pl:737] line 2. DB<5>

but Deparse fails to cover this with -x7

>>perl -MO=Deparse,-x7 -e"if (my $x =1) { print $x }; print $x" my $x = 1 and do { print $x }; print $x; # <-- no error under strict! -e syntax OK

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11110299]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-03-29 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found