Skip to content

Instantly share code, notes, and snippets.

@chrisa
Created September 1, 2008 18:15
Show Gist options
  • Save chrisa/8325 to your computer and use it in GitHub Desktop.
Save chrisa/8325 to your computer and use it in GitHub Desktop.
#!/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