Clarification on chomp

后端 未结 5 1086
旧时难觅i
旧时难觅i 2021-01-18 05:39

I\'m on break from classes right now and decided to spend my time learning Perl. I\'m working with Beginning Perl (http://www.perl.org/books/beginning-perl/) and I\'m finish

5条回答
  •  猫巷女王i
    2021-01-18 06:24

    is a short-cut notation for readline( *STDIN );. What readline() does is reads the file handle until it encounters the contents of $/ (aka $INPUT_RECORD_SEPARATOR) and returns everything it has read including the contents of $/. What chomp() does is remove the last occurrence contents of $/, if present.

    The contents is often called a newline character but it may be composed of more than one character. On Linux, it contains a LF character but on Windows, it contains CR-LF.

    See:

    perldoc -f readline
    perldoc -f chomp
    perldoc perlvar and search for /\$INPUT_RECORD_SEPARATOR/
    

提交回复
热议问题