Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How do I double up elements within an array?

by spivey49 (Monk)
on Aug 05, 2008 at 19:13 UTC ( #702458=note: print w/replies, xml ) Need Help??


in reply to How do I double up elements within an array?

I'm not sure what type of loop you tried, but this produces an array in the order you described:

use strict; use warnings; my @array1=(1,33,45,66); my @array2; for my $items(@array1){ push @array2,($items,$items); } for my $item(@array2){ print "$item\n"; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2019-12-09 18:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?