Rob Dixon wrote:
John W. Krahn wrote:
Strings like '%1\$s16->' are not valid sprintf/printf formats. What does your data look like and what do you expect it to look like after using sprintf?

From perldoc -f sprintf:

format parameter index
  An explicit format parameter index, such as "2$". By default
  sprintf will format the next unused argument in the list,
  but this allows you to take the arguments out of order,
  e.g.:

    printf '%2$d %1$d', 12, 34;      # prints "34 12"
    printf '%3$d %d %1$d', 1, 2, 3;  # prints "3 1 1"

Thank you for reading the documentation to me but '%1\$s' is not the same as '%1$s'.

$ perl -le'
    my $format = q[%s : %s : %1\$s] . "\n";
    my @data = qw[ one two three four ];
    printf $format, @data;
'
one : two : %1\$s

$ perl -le'
    my $format = q[%s : %s : %1$s] . "\n";
    my @data = qw[ one two three four ];
    printf $format, @data;
'
one : two : one




John
--
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to