Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 surveying the Monastery: (10)
As of 2014-12-28 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (178 votes), past polls