Skip to content

Instantly share code, notes, and snippets.

@xtetsuji
Created October 16, 2014 06:49
Show Gist options
  • Save xtetsuji/5a239dc50bf0e6b4b405 to your computer and use it in GitHub Desktop.
Save xtetsuji/5a239dc50bf0e6b4b405 to your computer and use it in GitHub Desktop.
Localize core function. Is this good?
#!/usr/bin/env perl
use strict;
use warnings;
BEGIN {
*CORE::GLOBAL::ref = sub { return "HELLO"; };
}
my $hash = {
aaa => 1,
bbb => 2,
};
print "hash is " . (ref $hash) . "\n";
*CORE::GLOBAL::ref = *CORE::ref;
print "hash is " . (ref $hash) . "\n";
__END__
output:
hash is HELLO
hash is HASH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment