Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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 ( #547133=note: print w/replies, xml ) Need Help??


in reply to Re: Counting the number of items returned by split without using a named array
in thread Counting the number of items returned by split without using a named array

Ha, great
print $count = $_ =~ s/\S+//g;

was probably what I wanted - just didnt know you could do that with a simple search (although I wondered if one couldnt just use a search in some way)

Thx a lot

Why does a simple
print $count = s/\S+//g;

not work, though?

This (as suggested below) did not count anything either:

$count = () = s/\S+//g;

I.

Replies are listed 'Best First'.
Re^3: Counting the number of items returned by split without using a named array
by borisz (Canon) on May 03, 2006 at 13:02 UTC
    I use m//g bellow __not__ s///g.
    Boris
Re^3: Counting the number of items returned by split without using a named array
by blazar (Canon) on May 03, 2006 at 13:11 UTC

    Although this may occasionally work for you in this circumstance, it's not logical to modify the original string just to count the number of occurrences. Just use /\S+/g instead.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://547133]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2021-01-19 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?