Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: The zen of code blocks

by Zaxo (Archbishop)
on Aug 24, 2001 at 00:30 UTC ( [id://107505]=note: print w/replies, xml ) Need Help??


in reply to The zen of code blocks

I looks like I'm long scooped, but this was too much fun to hurry :-) Thanks for the super question!

#!/usr/bin/perl -w use strict; sub zen { my $coderef = shift; # the code ref is a &$coderef; # Find the inner meaning[s] # &$coderef; }; my $petition = "How can I put a variable that is only visible to zen f +rom within this anon code block?"; zen do { my $speech = $petition; print $speech,$/; sub { $_ = shift; $speech = $speech =~ /^How/ ? $_ : "Mu."; print $speech,$/; } }, "There is do and there is not do.";

Update: Replaced tabs to fix formatting.

After Compline,
Zaxo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-18 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found