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.