There are functions in perl that tell you the number of characters in a string. You could use the "length" function, for example:
$string="fart";
$x=length($string);
This would set the value of $x to 4.
As far as recognizing words are concerned, you could use the "split" function to separate the string you're working on into elements of an array in which each element consists of 1 word. For example:
$string="I've just farted";
@stringarray=split(' ',$string);
In the above code, the elemets of the "@stringarray" array were set as follows:
$stringarray[0]="I've"
$stringarray[1]="just"
$stringarray[2]="farted"
So "@stringarray" actually contains the whole sentence separated into words.
2002-04-21 Edit by Corion : Added formatting
|