Hi Guys,
I am learning the object::insideout model now and can't find mush materials on
website. Do anyone know how to declare a hash data as attribute in object field
and how to use it.
I have example show below, but it seems not work properly. why the "first_para"
didn't show it's default value?
thanks
Christina
-----------------------source code -----------------
package BaseClass::configure; {
use Object::InsideOut;
my %parameters : Field = (
'first_para' => {
'Regex' => qr /^first$/i,
'Type' => 'number',
'default' => "ok",
},
);
sub set_parameter {
my $self = shift;
my %hash = ( 'first_1' => 1; 'second' => 2);
$self->set(\%parameters, \%hash);
print "seting done\n";
}
sub get_first{
my $self = shift;
my $hash = $parameters{$$self};
foreach my $k (keys %$hash) {print "$k -> $hash->{$k}\t"}
print "\n getting done\n";
}
}
package main;
my $obj = BaseClass::configure;
$obj->set_parameter;
$obj->get_first;
-------------results:------------
seting done
first_1 -> 1 second -> 2
getting done
_________________________________________________________________
Looking for a fresh way to share your photos? Check out the new Windows Live
Messenger
http://windowslive.ninemsn.com.au/article.aspx?id=792335