Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Problem creating array

by johngg (Canon)
on Sep 16, 2009 at 22:44 UTC ( [id://795724]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Problem creating array
in thread Problem creating array

A slightly simpler map at the cost of declaring another scalar.

$ perl -Mstrict -wle ' > my @count = ( 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 3, 2 ); > my $idx; > my @result = map { ( $idx ++ ) x $_ } @count; > print qq{@count}; > print qq{@result};' 1 3 1 1 1 1 1 2 1 1 3 2 0 1 1 1 2 3 4 5 6 7 7 8 9 10 10 10 11 11 $

I hope this is of interest.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-19 08:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found