Entry
Is it poss. to remove chars from the start of a string & specify the total no. of chars of the strin
Aug 31st, 2001 09:46
Tony Crosby, Jade Leth,
Sure is, If what you mean is you want a certain string to only be so
many characters long than this is especially easy.
$allowed_chars=9;
$string="This is a test string";
if (length($string) > 9){
$string=substr($string,length($string)-9,length($string));
}
print "$string";
Now $string is only 9 chars, and the last nine chars.
How wiered that may look, it actually works. Like Larry Wall himself
said though, the beauty of perl is there's never just one way of doing
it.
Tony