in reply to Newline in left-justified string for %s warning

When I run your two line of code I get the following warnings:

Newline in left-justified string for sprintf at ...noname.pl line 6. Use of uninitialized value in sprintf at ...noname.pl line 6. Newline in left-justified string for sprintf at ...noname.pl line 6. Use of uninitialized value in sprintf at ...noname.pl line 6. Newline in left-justified string for sprintf at ...noname.pl line 6. Use of uninitialized value in sprintf at ...noname.pl line 6.

Have you omited use warnings?


Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: Newline in left-justified string for %s warning
by pg (Canon) on Oct 10, 2005 at 05:26 UTC

    This code helps to explain those two warnings seperately:

    printf("%-2s", "\n"); printf("%s%s", "a");

    It prints:

    Newline in left-justified string for printf at math1.pl line 1. Use of uninitialized value in printf at math1.pl line 2. a

    The OP already provided the document that explains the first warning. The warning, to be frank, is meaningless. They just feel worried that you are probably confusing yourself ;-)

    The second warning was caused by the fact that we have two %s, which requires two strings, but only one is provided.

Re^2: Newline in left-justified string for %s warning
by Anonymous Monk on Oct 10, 2005 at 04:28 UTC
    I am using warnings and I am not getting the warnings. My Perl version:

    This is perl, v5.6.1 built for i686-linux

    The original sprintf that gives the warning is most likely running on a different platform (although I would have to check).

      I am using Active State v5.8.7 built for MSWin32-x86-multi-thread.


      Perl is Huffman encoded by design.