in reply to Dereferencing arrays

Try this:

use Data::Dumper; print Dumper($nextimg);

and see if that helps to explain things a little.

update: My guess is

that $nextimg is a reference to an array. When you cast it to an array, and then assign an array to a scalar, you get the size of that array. When you stringify an array, you get the array joined together by one of the special variables (sorry, my documentation is hosed right now, not certain which one it is).

--MidLifeXis