Что-то не могу понять, почему sprintf @_ возвращает не строку, а число элементов в списке, словно это и не sprintf, а какой-нибудь scalar. Странно! ( куча кода )
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
Ну я-то наивно предполагал, что sprintf возьмёт $_[0] как описание формата, а всё остальное - как аргументы. Оказалось, нифига: товарищ анонимус в ru_perl зацитировал 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. Типа, так и задумано.
Comments 3
Reply
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
Reply
Типа, так и задумано.
Reply
Leave a comment