Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- PERL 4.0 Reference Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

     chop(LIST)

     chop(VARIABLE)

     chop VARIABLE

             Chops off the last character of a string and returns
             the  character  chopped.   It's  used  primarily  to
             remove the newline from the end of an input  record,
             but  is  much  more efficient than s/\n// because it
             neither scans nor copies the string.  If VARIABLE is
             omitted, chops $_.  Example:

                  while (<>) {
                       chop;     # avoid \n on last field
                       @array = split(/:/);
                       ...
                  }

             You can actually chop  anything  that's  an  lvalue,
             including an assignment:

                  chop($cwd = `pwd`);
                  chop($answer = <STDIN>);

             If you chop a list, each element is  chopped.   Only
             the value of the last chop is returned.

See Also: substr

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson