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

Re: Looping through multiple arrays

by choroba (Cardinal)
on Mar 05, 2015 at 11:51 UTC ( [id://1118878]=note: print w/replies, xml ) Need Help??


in reply to Looping through multiple arrays

The first step: Fix the input. In your code sample, you created three arrays, each of them with just one member: an array reference.

Square brackets introduce array references. Use round parentheses () for lists.

@array1 = ('a','b','c'); @array2 = ('a','b'); @array3 = ('a','b','c','d');

How do you want to group the results?

#! /usr/bin/perl use warnings; use strict; use Syntax::Construct qw{ // }; my @array1 = ('a','b','c'); my @array2 = ('a','b'); my @array3 = ('a','b','c','d'); while (@array1, @array2, @array3) { print join ', ', map shift @$_ // 'NULL', \@array1, \@array2, \@ar +ray3; print "\n"; }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Looping through multiple arrays
by Anonymous Monk on Mar 05, 2015 at 12:12 UTC
    Sorry, its an array and not an array reference. Do you think this is legal?
    next if($array1|$array2|$array3) eq '';
    Seems to have solved the issue so far.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2026-04-22 21:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.