123

Built-In Functions
Chop

  • The chop() function removes the last character of each item

  • Scalar context

      $foo = "Hello\n";
      chop( $foo );
      # $foo is now "Hello"

  • List context

      @foo = ( "Goodbye\n", "cruell", "world\n" );
      chop( @foo );
      # @foo is now ( "Goodbye", "cruel", "world" )

  • Notice chop can remove more than simply "\n" characters!