ablog

不器用で落着きのない技術者のメモ

Perl の特殊変数で $/ ってなんだっけ?

% perldoc perl

...

   Reference Manual

...

           perlvar             Perl predefined variables
           perlre              Perl regular expressions, the rest of the story
% perldoc perlvar
       $/      The input record separator, newline by default.  This
               influences Perl's idea of what a "line" is.  Works like awk's
               RS variable, including treating empty lines as a terminator if
               set to the null string.  (An empty line cannot contain any
               spaces or tabs.)  You may set it to a multi-character string to
               match a multi-character terminator, or to "undef" to read
               through the end of file.  Setting it to "\n\n" means something
               slightly different than setting to "", if the file contains
               consecutive empty lines.  Setting to "" will treat two or more
               consecutive empty lines as a single empty line.  Setting to
               "\n\n" will blindly assume that the next input character
               belongs to the next paragraph, even if it's a newline.
               (Mnemonic: / delimits line boundaries when quoting poetry.)