Skip to content

Instantly share code, notes, and snippets.

@exodist
Created January 6, 2012 21:50
Show Gist options
  • Save exodist/1572555 to your computer and use it in GitHub Desktop.
Save exodist/1572555 to your computer and use it in GitHub Desktop.
package Foo;
use strict;
use warnings;
use Test::More;
BEGIN { $INC{'Foo.pm'} = __FILE__ }
sub import {
my $class = shift;
my $caller = caller;
no strict 'refs';
*{"$caller\::foo"} = sub {
$^H{'Foo'} ||= bless {'caller' => $caller}, $class;
};
}
sub DESTROY {
my $self = shift;
local $SIG{__DIE__} = sub { warn @_; exit 1 };
print "doing something like $self->{caller}\->meta->make_immutible...\n";
}
package Bar;
use strict;
use warnings;
use Test::More;
use Data::Dumper;
use Foo;
print "A\n";
foo blah => (
doesnt => 'matter',
);
print "B\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment