in reply to Dereferencing arrays

I'm assuming the 1 is the return code for "all good!".
No... If you do
$scalar = @array;
then what you assign to $scalar is the count of items in @array (array in scalar context). Apparently it contains one item.

What you probably want (it's hard to say with the rest of the code not there) is getting the first item of the array. One way to achieve that is using parens: they make the assignment happen in list contxt, and the first item is assigned to $scalar:

($scalar) = @array;

Applying this rule to your code, I think

($next) = @{$nextimg};
will do what you want.

Another way is to use an array index:

$scalar = $array[0];
Hence
$next = ${$nextimg}[0];