> -----Original Message-----
> From: Steven Jackson [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 20, 2003 11:24 AM
> To: [EMAIL PROTECTED]
> Subject: Counting words in a line?
> 
> 
> Hi,
> 
> this is my first post, so go ahead, call me a newbie.
> 
> How do I count the number of words in a line?  I need to convert some
> astronomy data which has floats, integers and commas in the string and
> massage this data into something more palatable to the application.
> 
>

Depends on what you define as a word.
Nonetheless, here's a way:

<snip>
use strict;

my $s = 'hi there how are you';
my @w = ($s =~ /\w+/g);
print $#w+1;
</snip>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to