ja660k
June 17th, 2010, 10:23 AM
Hey all, Perl exam tomorrow.
and theres a question in the sample exam that i dont quite understand.
the code is very perlish
Briefly explain each line
package Counter;
sub TIESCALAR {
my $class = shift;
my $value = shift || 0;
bless \$value => $class;
}
sub FETCH { return ++ ${$_[0]};}
sub STORE { return ${$_[0]} = $_[1];}
and my understanding is..
tiescalar takes a package name, and creates an object to $class with the value of $value
and
store and fetch. im confused on :(
any help would be great.
and theres a question in the sample exam that i dont quite understand.
the code is very perlish
Briefly explain each line
package Counter;
sub TIESCALAR {
my $class = shift;
my $value = shift || 0;
bless \$value => $class;
}
sub FETCH { return ++ ${$_[0]};}
sub STORE { return ${$_[0]} = $_[1];}
and my understanding is..
tiescalar takes a package name, and creates an object to $class with the value of $value
and
store and fetch. im confused on :(
any help would be great.