in reply to Local Subroutines

It sounds like you're really looking for objects, not subroutines.

That said, you can do something like:

sub foo { my ($start, $num) = @_; my $_foo; *_foo = sub { # Do stuff here }; my @return = $_foo->($start, $num); return @return; }

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

Replies are listed 'Best First'.
Re: Re: Local Subroutines
by Roy Johnson (Monsignor) on May 27, 2004 at 19:22 UTC
    Aren't you globbing a lexical here?

    The PerlMonk tr/// Advocate
      Lexicals can't be globbed (whatever that means ;) because they're lexical, not global (they don't live in the symbol table):
      my $foo = sub {'i am $foo '}; *foo = sub{'i am *foo '}; print $foo->(), $foo,$/; print foo(), \&foo,$/; __END__ i am $foo CODE(0x1ab2860) i am *foo CODE(0x1ab28e4)

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Re: Local Subroutines
by sweetblood (Prior) on May 27, 2004 at 19:31 UTC
    I've always managed to skirt around objects, using them only when I have to, but never creating my own. I've been programming over 20 years(not always Perl), so objects were never part of my vernacular except of course as in my roll as a sex object(maybe not). I suppose this is a good time to finally bite the bullet.

    Thanks!
    Sweetblood