Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Overloading oddity

by theguvnor (Chaplain)
on Jan 27, 2004 at 21:41 UTC ( [id://324542]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    package SomeClass;
    use overload '""'=>"name";
    ...
        return $self->{NAME};
    }
    1;
    
  2. or download this
    use lib '.';
    use SomeClass;
    ...
    print "Explicit: my name is ", $thing->name, "\n";
    print "Implicit: my name is $thing\n";
    exit;
    
  3. or download this
    sub stringify {
        my $self = shift;
        return $self->{NAME};
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://324542]
Approved by kvale
Front-paged by bart
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-16 11:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found