in reply to what's difference between bless and tie?
With tie you bless a named variable, and a predefined set of methods for that variable type are called automatically as the variable is used.
It allows the variables to be used exactly as if they were normal Perl variables of that type rather than requiring the methods be called using object syntax, which makes for very natural usage:
tie my @array, 'Some::Thing'; ... $array[ $n ] *= 5;
Rather than the clumsy:
my $myObj = Some::Thing->new(); ... $myObj->setItem( $n, $myObj->getItem( $n ) * 5 );
|
|---|