Skip to content

Instantly share code, notes, and snippets.

@schwern
Created May 12, 2010 23:38
Show Gist options
  • Select an option

  • Save schwern/399278 to your computer and use it in GitHub Desktop.

Select an option

Save schwern/399278 to your computer and use it in GitHub Desktop.
#!perl
use strict;
use warnings;
use autobox;
sub UNIVERSAL::mo {
return Meta::Instance->new($_[0]);
}
{
package Meta::Instance;
sub new {
my $class = shift;
# Be careful to take a reference to an alias, not a copy
return bless \$_[0], $class;
}
sub echo {
my $self = shift;
return $$self;
}
}
print "UNIVERSAL"->mo->echo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment