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
|
|---|