I've always wondered if this would work, but never tried it until now. It worked on the first try. Does that say more about me or Perl?
#!/usr/bin/perl -w use strict; sub installsub: lvalue { my $glob = shift; no strict 'refs'; *{ $glob }; } installsub( 'foo' ) = sub { print "Foo!\n" }; foo();
Of course, that's not bad enough:
for my $sub (qw( bar baz )) { installsub( $sub ) = sub { print "$sub\n" }; __PACKAGE__->can( $sub )->(); }
Worse yet, I have an actual factual practical use in mind.
Um, er, ah
It says you are one sick puppy.
Of course, Abigail isn't very far. But we already knew that.
I should really stop replying to journals on Friday....