Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Is it possible to create a sub exclusive to a sub?

by FoxtrotUniform (Prior)
on Sep 19, 2004 at 00:30 UTC ( [id://392073]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Is it possible to create a sub exclusive to a sub?
in thread Is it possible to create a sub exclusive to a sub?

D'oh! My fault; the anonymous sub block needs to be delimited with a semicolon. Code changed.

Here's a minimal example of what I think you're looking for:

#! /usr/bin/perl -w use strict; sub foo { print "in foo\n"; my $bar = sub { print "in bar\n"; }; if(0 == @_) { $bar->(); } else { for (@_) { print "foo called with $_; "; $bar->(); } } } &foo(); &foo(qw(one two three));

--
F o x t r o t U n i f o r m
Found a typo in this node? /msg me
% man 3 strfry

Replies are listed 'Best First'.
Re^4: Is it possible to create a sub exclusive to a sub?
by punkish (Priest) on Sep 19, 2004 at 00:34 UTC
    putting a semi (and correcting one of my own stupidities) results in everything running correctly. All's happy in punkish's perl land... thanks FoxtrotUniform.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-19 22:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found