Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

My HEREDOC is simple:

printf<<'END'; %U %S %A END

But the output is:

0
%S
%A

What? What happened to the %U? Noticed this with some other chars too, like %X.

version is
perl -v
This is perl 5, version 16, subversion 3 (v5.16.3)
on Windows7

Thanks for any tips.

Replies are listed 'Best First'.
Re: HEREDOC weirdness
by AppleFritter (Vicar) on Sep 03, 2014 at 21:28 UTC

    You're using printf, not print, so your heredoc actually specifies a format string. Is that on purpose?

    Note that %U is one of the formats recognized by printf, BTW, as is %X; OTOH, %S and %A aren't, so they're printed unmodified.

      No, it was not, and that appears to be the answer.

      Thanks so much!!

        You're welcome! *tips hat*

        BTW, allow me to also suggest that you make it a habit to use warnings - this would've provided a valuable clue here:

        Missing argument in printf at 1099478.pl line 7. Missing argument in printf at 1099478.pl line 7. Invalid conversion in printf: "%S" at 1099478.pl line 7. Missing argument in printf at 1099478.pl line 7. Invalid conversion in printf: "%A" at 1099478.pl line 7.