simple question on perl

Ben Pfaff pfaffben@msu.edu
01 Sep 2000 17:13:53 -0400


Sean <picasso@madflower.com> writes:

> $one_char = substr ($string -1, 1);

That doesn't take off the last character.  It subtracts 1 from
$string and drops the first character.  You probably meant to
include another `,':
	$last_char = substr ($string, -1, 1);
although you can also leave off the last argument in this case:
	$last_char = substr ($string, -1);