manpagez: man pages & more
info gettext
Home | html | info | man

File: gettext.info,  Node: Long Lines,  Next: Perl_Pitfalls.php">Perl Pitfalls,  Prev: Parentheses,  Up: Perl

16.5.27.8 How To Grok with Long Lines
.....................................

   The necessity of long messages can often lead to a cumbersome or
unreadable coding style.  Perl has several options that may prevent you
from writing unreadable code, and ‘xgettext’ does its best to do
likewise.  This is where the dot operator (the string concatenation
operator) may come in handy:

     print gettext ("This is a very long"
                    . " message that is still"
                    . " readable, because"
                    . " it is split into"
                    . " multiple lines.\n");

   Perl is smart enough to concatenate these constant string fragments
into one long string at compile time, and so is ‘xgettext’.  You will
only find one long message in the resulting POT file.

   Note that the future Perl 6 will probably use the underscore (‘_’) as
the string concatenation operator, and the dot (‘.’) for dereferencing.
This new syntax is not yet supported by ‘xgettext’.

   If embedded newline characters are not an issue, or even desired, you
may also insert newline characters inside quoted strings wherever you
feel like it:

     print gettext ("In HTML output
     embedded newlines are generally no
     problem, since adjacent whitespace
     is always rendered into a single
     space character.");

   You may also consider to use here documents:

     print gettext <In HTML output
     embedded newlines are generally no
     problem, since adjacent whitespace
     is always rendered into a single
     space character.
     EOF

   Please do not forget that the line breaks are real, i.e. they
translate into newline characters that will consequently show up in the
resulting POT file.

© manpagez.com 2000-2026
Individual documents may contain additional copyright information.