Scalar Data

The chop and chomp functions

The chop function chops off the last character of a string and returns the character chopped.


$a = "Molecular Biology";
$b = chop($a);

now $a is:   Molecular Biolog
and $b is:   y

chomp is slightly a safer version of chop in that it removes only the last newline character, and not any last character.

Use chop and chomp only with variables, not with literal values.


$b = chop ("Molecular Biology");

is illegal!

Table of Contents.
Previous | Next.