Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Functional Programming & method rewriting

by SpanishInquisition (Pilgrim)
on Oct 28, 2004 at 22:20 UTC ( #403535=note: print w/replies, xml ) Need Help??


in reply to Re: Functional Programming & method rewriting
in thread Functional Programming & method rewriting

Hmm, I did go the long way to do it, didn't I? :)
Thanks for the idea.

sub foo { print "hi mom\n"; my $ptr = \&foo; *foo=sub { print "that was unneccessary:"; $ptr->(); }; } foo(); foo();

Hmm, more Perl voodoo. I like it.

Replies are listed 'Best First'.
Re^3: Functional Programming & method rewriting
by Sandy (Curate) on Oct 29, 2004 at 21:55 UTC
    Using your subroutine, try running
    foo(); foo(); foo(); foo();
    or for the really dangerous,
    foo() for (1..1000);

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2023-06-10 08:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (38 votes). Check out past polls.

    Notices?