Created
February 12, 2013 22:48
-
-
Save exodist/4774202 to your computer and use it in GitHub Desktop.
eval example
This file contains hidden or 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
package My::Thing; | |
use strict; | |
BEGIN { | |
$INC{'My/Thing.pm'} = __FILE__; | |
} | |
sub import { | |
my $caller = caller; | |
eval <<" EOT" || die $@; | |
package $caller; | |
print "Caller: \$caller\n"; | |
use vars qw/\@foo \$bar/; | |
EOT | |
} | |
package consumer; | |
use strict; | |
use My::Thing; | |
$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