in reply to Difference between tie and bless
is shorthand to tell perl to execute$ref->method(@args)
where Foo::Bar is the package that the thingy pointed to by $ref has been blessed into. If the 'method' sub doesn't exist in Foo::Bar, then Perl looks in the packages listed in @Foo::Bar::ISA for a sub called 'method', and so on.Foo::Bar::method($ref, @args)
Tying is something completely unrelated, and only has a marginal conection with OO (in the sense that it's implemented using OO). It's used when you want to take control of how a variable is accessed.
callstie @arr, Foo::Bar, @args
and this sub is supposed to return a blessed object of some type (not necessarily an array). Perl then attaches this object to the variable in question (@arr), and marks it as being tied. Any subsequent access of this variable (eg $arr[3] = 4) is intercepted, and rather than modifying the contents of the real array, a method is called on its associated object, egFoo::Bar->TIEARRAY(@args)
$hidden_object->STORE(3,4);
Dave.
|
|---|