in reply to Re^2: Joining an array
in thread Joining an array

When you tie a variable, the TIE* method, in this case TIESCALAR, has to return an object. An object is nothing more than a blessed reference. \my $i is a reference to the variable $i. bless blesses its argument. If bless is given just one argument, it blesses the reference to the current package.

The first argument to the FETCH method is the object returned from bless. $_[0] is the first argument of a method, and ${EXPRESSION THAT RETURNS A SCALAR REFERENCE} is a way to dereference a scalar reference. So, you get back the $i.

Replies are listed 'Best First'.
Re^4: Joining an array
by chessgui (Scribe) on Feb 12, 2012 at 11:17 UTC
    I was confused because I've thought that explicitly blessing with a class name was a must. However it is just a good practice becoming significant with inheritance (which is not the case here).
    Give a man a fish and you feed him for a day. Give him a fishnet and you feed him for a lifetime. Ooops! Wait a minute! What if the fishnet brakes down? He will ask for an other fishnet or worse starve to death. Better yet to teach him how to make a fishnet. But what if he forgets how to make a fishnet? It is better to teach him where to look for knowledge on how to make a fishnet. But this can also go wrong. So ultimately it is best just telling him: 'Help yourself, stupid!'