in reply to Counting elements in array

When you incorporate @array into a double-quoted construct it is interpolated as a list of elements, rather than with scalar context. The list separator in double-quoted constructs is usually " " (the space character), but can be changed to just about anything by setting $".

So you might think, "Well, I'll just do this: print @array, "\n";.", which would be wrong again, because once again @array is being evaluated in list context, which just returns the elements (this time separated by whatever is set in "$,".

You have to give @array scalar context. Here are a couple of ways:

my $size = @array; print "$size\n"; # or... print scalar(@array), "\n"; # or .. print @array . "\n"; # Because '.' invokes scalar context on its opera +nds.

Dave