Created
September 1, 2008 18:15
-
-
Save chrisa/8325 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
package Probe; | |
use Scalar::Util qw/ set_prototype /; | |
sub create_function { | |
my ($answer) = @_; | |
*Probe::block = sub (&) { | |
shift->($answer); | |
}; | |
set_prototype(\&Probe::block, '&'); | |
} | |
package main; | |
BEGIN { | |
Probe::create_function(42); | |
} | |
Probe::block { print "the answer is $_[0]\n" }; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment