Perl chop Function
This function removes the last character from EXPR, each element of LIST, or $_ if no value is specified.
Following is the simple syntax for this function:
chop VARIABLE chop( LIST ) chop
This function returns the character removed from EXPR and in list context, the character is removed from the last element of LIST.
Following is the example code showing its basic usage:
#!/usr/bin/perl $string1 = "This is test"; $retval = chop( $string1 ); print " Choped String is : $string1\n"; print " Character removed : $retval\n";
When above code is executed, it produced following result:
Choped String is : This is tes Number of characters removed : t