in reply to Counting the number of items returned by split without using a named array
Here is one way to do it.
use strict; use warnings; $_ = 'here the text goes'; my @entries; print scalar (@entries = split /\s+/, $_);
Without return list, here is one way
use strict; use warnings; $_ = 'here the text goes'; my $count; print $count = $_ =~ s/\S+//g;
updated: Added second method as blazar pointed out, without return list, though not a most elegant way. Thanks.
Prasad
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Counting the number of items returned by split without using a named array
by blazar (Canon) on May 03, 2006 at 10:53 UTC | |
Re^2: Counting the number of items returned by split without using a named array
by Anonymous Monk on May 03, 2006 at 12:53 UTC | |
by borisz (Canon) on May 03, 2006 at 13:02 UTC | |
by blazar (Canon) on May 03, 2006 at 13:11 UTC |