Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: not able to get the output using split function

by GrandFather (Sage)
on Sep 03, 2012 at 05:09 UTC ( #991352=note: print w/ replies, xml ) Need Help??


in reply to not able to get the output using split function

my $i; for ($i = 0; $i < scalar(@words); $i++) { print "$i: " . $words[$i] . "\n"; }

is better written:

for my $i (0 .. $#words) { print "$i: $words[$i]\n"; }

or could be written using for as a statement modifier as:

print "$_: $words[$_]\n" for 0 .. $#words;
True laziness is hard work


Comment on Re: not able to get the output using split function
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2015-07-29 03:30 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