Manual

- Overview
- Tutorials
- FAQs
- History / Changes
- License

Reference

- Language
- Functions
- Operators
- Special Variables
- Pragmas
- Utilities
- Internals
- Platform Specific

Modules

- A • B • C • D • E
- F • G • H • I • L
- M • N • O • P • S
- T • U • X

News / Blogs

- Perl Buzz
- Perl Iron Man
- Perlsphere
- Planet Perl
- TPF news
- Use Perl

See also

- CPAN
- Perl.org
- Perl.com
- Perl 5 Wiki
- Perl Jobs
- Perl Mongers
- Perl Monks

Contact

- Site designed and maintained by Jon Allen (JJ)
- http://perl.jonallen.info

- View the project page and FAQs

# chop

Perl 5 version 10.1 documentation
Go to top

# chop

Perl functions A-Z | Perl functions by category | The 'perlfunc' manpage

- chop VARIABLE

- chop( LIST )
- chop

  Chops off the last character of a string and returns the character chopped. It is much more efficient than `s/.$//s` because it neither scans nor copies the string. If VARIABLE is omitted, chops `$_` . If VARIABLE is a hash, it chops the hash's values, but not its keys.

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

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

  Note that `chop` returns the last character. To return all but the last character, use `substr($string, 0, -1)` .

  See also "chomp".

Recently read

Tools

- Preferences