note
Abigail-II
As you said, substr is the way to go. <tt>chop</tt> chops off one character, and not more than one. So, if you want to chop off 4 characters using <tt>chop</tt>, you need to <tt>chop</tt> 4 times. Either by duplicating the line, or by using a loop. You might want to bail out if the string is empty:
<code>
my $i = 4;
chop $string while $i -- && length $string;
</code>
Or
<code>
my $i = 4;
1 while $i -- && defined chop $string;
</code>
although the latter might want to chop an empty string (but only once).
<p>
Abigail
369291
369291