Skip to content

Instantly share code, notes, and snippets.

@exodist
Last active December 12, 2015 12:48
Show Gist options
  • Save exodist/4774332 to your computer and use it in GitHub Desktop.
Save exodist/4774332 to your computer and use it in GitHub Desktop.
no eval
package My::Thing;
use strict;
BEGIN {
$INC{'My/Thing.pm'} = __FILE__;
}
sub import {
my $class = shift;
my $caller = caller;
my $string = "Foo";
my $sym = "$caller\::bar";
no strict 'refs';
*$sym = \$string;
}
package consumer;
use strict;
use My::Thing;
print("Bar: $bar\n");
$bar = "This is sparta!";
print("Bar: $bar\n");
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment