Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: how to print two array with new line at end of each second array element, using a single print statement?

by eyepopslikeamosquito (Archbishop)
on Apr 21, 2012 at 06:32 UTC ( [id://966313]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @nums = (1, 2, 4, 5, 8, 9);
    my @dat =  (3, 9, 14, 10, 12, 8);
    for my $i ( 0 .. $#nums ) {
        print "$nums[$i] $dat[$i]\n";
    }
    
  2. or download this
    use List::MoreUtils qw(zip natatime);
    
    ...
    while ( my @vals = $it->() ) {
        print "@vals\n";
    }
    
  3. or download this
    use List::MoreUtils qw(pairwise);
    
    my @nums = (1, 2, 4, 5, 8, 9);
    my @dat =  (3, 9, 14, 10, 12, 8);
    print pairwise { "$a $b\n" } @nums, @dat;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (8)
As of 2024-04-18 08:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found