Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created November 2, 2013 19:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leejarvis/7282546 to your computer and use it in GitHub Desktop.
Save leejarvis/7282546 to your computer and use it in GitHub Desktop.
{
package User;
sub new {
my $class = shift;
my $self = {};
$self->{name} = shift;
bless $self, $class;
};
use overload fallback => 1,
'""' => sub { shift->{name} };
}
my $u = User->new("Lee");
print "My name is $u\n"; #=> My name is Lee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment