Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: understanding closures

by demerphq (Chancellor)
on Sep 23, 2005 at 17:08 UTC ( [id://494604]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    D:\dev>perl -e"do { next };"
    Can't "next" outside a loop block at -e line 1.
    
    D:\dev>perl -e"{ next };"
    
  2. or download this
    BEGIN {
        my $count=0; # static
    ...
    for (0..9) {
        print counter();
    }
    
  3. or download this
    sub make_counter {
      my $start=shift||0;
      return sub {$start++};
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (8)
As of 2024-04-16 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found