I don't know whether substr is optimized not to bother returning anything in void context (probably is), but this is how you do it
my $long_string = 'string' x 5;
print $long_string,$/;
substr( $long_string, 6 ) = ''; # truncate to 6 characters
#
# same thing, only using 4 arg substr
# substr( $long_string, 6, length($long_string) - 6, '' );
#
print $long_string,$/;
__END__
stringstringstringstringstring
string
MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" |
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). |
** The third rule of perl club is a statement of fact: pod is sexy. |