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
In reply to Re^3: Is it possible to create a sub exclusive to a sub?
by FoxtrotUniform
in thread Is it possible to create a sub exclusive to a sub?
by punkish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |