Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Perl newbie question.

by kiruthika.bkite (Scribe)
on Mar 19, 2010 at 09:24 UTC ( #829576=note: print w/ replies, xml ) Need Help??


in reply to Re: Perl newbie question.
in thread Perl newbie question.

my $nr = split (/\s+/, $_[0]);

We can get the number of elements by simply assigning the return value of split into a scalar variable.

Example
$str="1:3:4:5"; my $num=split(':',$str); print "Num:$num";

$num will contain '4'.


Comment on Re^2: Perl newbie question.
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2015-07-29 07:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls