Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Objects as arrays but with autogenerated getters + setters

by Solo (Deacon)
on Jun 26, 2006 at 22:34 UTC ( [id://557673]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Objects as arrays but with autogenerated getters + setters
in thread Objects as arrays but with autogenerated getters + setters

package Foo; use Class::MakeMethods::Template::Array ( 'new' => 'new', 'scalar' => [ -interface=> { 'get_*'=>'get', 'set_*'=>'set' }, qw/ name age city job salary /, ], ); package main; use Data::Dumper; my $foo = Foo->new(); $foo->set_name("foo"); $foo->set_age(100); warn Data::Dumper->Dump([$foo], ['foo']); print $foo->get_age,$/; $foo->set_age(23); print $foo->get_age,$/;

--Solo

--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.

Replies are listed 'Best First'.
Re^4: Objects as arrays but with autogenerated getters + setters
by tinita (Parson) on Jun 26, 2006 at 23:01 UTC
    thank you so much. sometimes one needs such an example to get a starting point =)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://557673]
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: (4)
As of 2024-04-19 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found