Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Refactoring: sub within a sub

by tobyink (Canon)
on Jul 25, 2012 at 19:44 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://983726]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-18 05:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found