Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Closure warning with Perl 5.14?

by ikegami (Patriarch)
on May 19, 2011 at 09:50 UTC ( [id://905648]=note: print w/replies, xml ) Need Help??


in reply to Closure warning with Perl 5.14?

You can get that warning from the following even before 5.14:

use strict; use warnings; sub foo { my ($x) = @_; return sub { eval 'print "$x\n";' }; } sub bar { my ($x) = @_; return sub { $x if 0; eval 'print "$x\n";' }; } foo("foo")->(); bar("bar")->();

(Note: The if 0 just avoids a void context warning. Removing it doesn't change the outcome.)

That you also get it in 5.14 under some circumstances involving illegal code (my ... if ...;) is not a problem.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2024-04-23 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found