Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: issue with print/join 2 arrays

by RichardK (Parson)
on Apr 29, 2014 at 17:08 UTC ( #1084357=note: print w/replies, xml ) Need Help??

in reply to issue with print/join 2 arrays

But what should happen when the length of the first array isn't a multiple of 3?

Replies are listed 'Best First'.
Re^2: issue with print/join 2 arrays
by juanito23 (Novice) on Apr 29, 2014 at 18:37 UTC
    Hi!, thanks for all replies, but yes.. The arrays I will have to print have more than 1000 rows per 3 columns... Any way to do it then? One other thing.. What if the length of both arrays are different? Thanks!!

      Just adapt the solution I gave in my other post:

      say join ' ', map splice( $_, 0, 3 ), \@array1, \@array2 while @array1 or @array2;

      If you need to access your original arrays later, make copies and destroy these instead.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1084357]
[ikegami]: That should be ${ $hash{$key} }[$_] because it's $a[$_] when you don't use a ref.
[oiskuu]: James, that's an array slice you have there (over some hash value)
[ikegami]: Mini-Tutorial: Dereferencing Syntax

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2017-04-27 19:30 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (512 votes). Check out past polls.