Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Refactoring: sub within a sub

by tobyink (Abbot)
on Jul 25, 2012 at 19:44 UTC ( #983726=note: print w/replies, xml ) Need Help??


in reply to Refactoring: sub within a sub

use strict; use Digest::SHA 'sha1_hex'; sub get_hash_printer { my $str = shift; my $hash = sha1_hex($str); return sub { print "$hash\n"; } } my $hash_printer = get_hash_printer("Hello"); $hash_printer->(); __END__ f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2018-08-17 11:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (178 votes). Check out past polls.

    Notices?