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

Re: simple anonymous subroutine and variable interpolation timing question

by ikegami (Patriarch)
on Jun 23, 2011 at 20:07 UTC ( #911150=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub make_closure {
       my ($str) = @_;
    ...
    say $sub->();   # 'hi'
    $str = 'hello';
    say $sub->();   # 'hi'
    
  2. or download this
    my $str = 'hi';
    my $sub = eval qq{ sub { "\Q$str\E" } } or die $@;
    ...
    say $sub->();   # 'hi'
    $str = 'hello';
    say $sub->();   # 'hi'
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2023-04-01 03:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?