This function takes a single argument within its parentheses - the name of a scalar variable - and removes the last character from the string value of that variable. For example:
$x = "hello world";
chop($x); # $x is now "hello worl"
Note that the value of the argument is altered here, hence the requirement for a scalar variable, rather than simply a scalar value. It would not make sense, for example, to write chop('suey') to change it to 'sue', because there is no place in which to save the value. Besides, you could have just written 'sue' instead.
The value returned is the discarded character (the letter d in world above). This means that the following code is probably wrong:
$x = chop($x); # WRONG: replaces $x with its last character
chop($x); # RIGHT: as above, removes the last character
If chop is given an empty string, it does nothing, and returns nothing, and doesn't raise an error or even whimper a bit.1
Most operations in Perl have sensible boundary conditions; in other words, you can use them right up to the edges (and beyond), frequently without complaint. Some have argued that this is one of Perl's fundamental flaws, while others write screaming programs without having to worry about the fringes. You decide which camp you wish to join.
When you chop a string that has already been chopped, another character disappears off into "bit heaven." For example:
$a = "hello world\n";
chop $a; # $a is now "hello world"
chop $a; # oops! $a is now "hello worl"
Another useful built-in function is the previously seen chomp.