----- Original Message ----- 
From: "Richard Müller" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, May 31, 2003 8:04 AM
Subject: count of words (fields) after "split"


Hi,
I'm a very newbie with perl. I have a text file and want to read it line
by line and split it into words:
my @fields = split / /, $_;
- so far no problem.
Now I have to count the words in the line. This I could not achieve.
I#m sure it is very simple - but I did not find the suitable command
-- 
Richard Müller - Am Spring 9 - D-58802 Balve
[EMAIL PROTECTED] - www.oeko-sorpe.de

Hi -

The count of elements in an array is returned when
you access that array in 'scalar' cintext; there are
many ways to do this:

  my $count = @fields;
  print "number of fields = $count\n";

  printf "number of fields = %d\n", scalar @fields;

  etc, etc.

Aloha => Beau;




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

Reply via email to