(gettext.info)Long Lines


Next: Perl Pitfalls Prev: Parentheses Up: Perl
Enter node , (file) or (file)node

15.5.18.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 ("<em>In HTML output
     embedded newlines are generally no
     problem, since adjacent whitespace
     is always rendered into a single
     space character.</em>");

   You may also consider to use here documents:

     print gettext <<EOF;
     <em>In HTML output
     embedded newlines are generally no
     problem, since adjacent whitespace
     is always rendered into a single
     space character.</em>
     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.


automatically generated by info2www version 1.2.2.9