Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: how to use attributes?

by varian (Chaplain)
on Mar 22, 2007 at 18:34 UTC ( [id://606088]=note: print w/replies, xml ) Need Help??


in reply to how to use attributes?

':Constructor' is not a valid Perl attribute,
Just replace those attributes by the word ':method' and your code will run fine.
package Attr; sub new :method { return bless {}, shift } sub set_blah :method { my ( $self, $blah ) = @_; $self->{blah} = $blah; return $self; } sub get_blah :method { my $self = shift; return $self->{blah}; } 1; package main; my $obj = Attr->new; $obj->set_blah('I just set something!'); print $obj->get_blah;

Replies are listed 'Best First'.
Re^2: how to use attributes?
by rvosa (Curate) on Mar 22, 2007 at 19:01 UTC
    Thanks for the reply, but I said arbitrary attributes. If I can only set the attribute "method", then that reminds me of Henry Ford saying you can have your Model T in any color you like, as long as that color is "black".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2024-04-18 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found