Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Why is a hash the default "object" in oo perl?

by tinita (Parson)
on Jul 18, 2004 at 01:51 UTC ( #375309=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub _attr {
      my $self = shift;
      my $name = shift;
    ...
      $self->{"_$name"} = shift;
    }
    sub name { shift->_attr(name => @_); }
    
  2. or download this
    package Parent;
    use attribute sub {
    ...
      # we have an ordinary hashref for the object
      return \$self->{"_$name"};
    }, [qw(city name)];
    
  3. or download this
    package Child;
    use base 'Parent';
    ...
      # object is arrayref, and the attributes are stored in element 0
      return \$self->[0]->{"_$name"};
    };
    
  4. or download this
    package attribute;
    use strict;
    use warnings;
    ...
      }
    }
    1;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://375309]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (14)
As of 2015-07-28 16:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls