Create a new account
I've found this odd thing with sprintf, probably to do with it's prototype.
I would have thought that sprintf @list would do the same as sprint shift @list, @list, but it's doesn't. The former will return the number of elements in @list.
From "perldoc -f sprintf":
Unlike "printf", "sprintf" does not do what you probably mean when you pass it an array as your first argument. The array is given scalar context, and instead of using the 0th element of the array as the format, Perl will use the count of elements in the array as the format, which is almost never useful.
"Perl will use the count of elements in the array as the format, which is almost never useful."
When would that be useful? I can't think of a single case.
It's a good example of getting bitten by an unexpected prototype though...
Get More Comments