Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: printing arrays

by Arunbear (Parson)
on Dec 31, 2008 at 14:41 UTC ( #733475=note: print w/replies, xml ) Need Help??

in reply to printing arrays

Assuming there are as many ids as names:

use strict; use warnings; my @ids = (123, 456, 789); my @names = qw(Smith Doe Allen); foreach my $i (0 .. $#ids) { print "$ids[$i] $names[$i]\n"; }

Replies are listed 'Best First'.
Re^2: printing arrays
by kdj (Friar) on Dec 31, 2008 at 14:45 UTC

    You actually wouldn't want the \n on the end of

         print "$ids[$i] $names[$i]\n";

    That would only print one id/name combination per line, and (s)he wants the entire contents of both arrays on one line. Replace the \n with a space and it should work.

      ..thanks kdj - have a good new year's eve..
Re^2: printing arrays
by Spooky (Beadle) on Dec 31, 2008 at 15:14 UTC
    ..thanks for the input - have a safe new year's eve!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://733475]
[LanX]: Bishop LanX starts singing: ♪..♫ I want it all ...♩..♬
LanX ♪..♫ ...and I want it now!!! ♩..♬
[LanX]: damn my headphones were not plugged and the video blasted thru the office ...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2017-09-20 15:41 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (237 votes). Check out past polls.