Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: issue with print/join 2 arrays

by Not_a_Number (Prior)
on Apr 29, 2014 at 18:08 UTC ( [id://1084372]=note: print w/replies, xml ) Need Help??


in reply to issue with print/join 2 arrays

use 5.010; my @array1 = ( 1, 2, 3, 1, 2, 3, 1, 2, 3 ); my @array2 = qw( blue white yellow blue white yellow blue white yellow + ); say join ' ', map splice( $_, 0, 3 ), \@array1, \@array2 while @array1 +;

But beware, this is destructive to both arrays.

Replies are listed 'Best First'.
Re^2: issue with print/join 2 arrays
by Laurent_R (Canon) on Apr 29, 2014 at 21:18 UTC
    Although your solution is quite good and probably does what is wanted, I tend to prefer BrowserUk's, because it does not destroy the original array.

    Edit: added the word "not" which was missing and gave an opposite meaning to the last part of my sentence. Thanks to Bloodnok++ for having pointed out that mistake.

      ... or, more particularly, BrowserUk's, because it doesn't destroy the array :-)

      A user level that continues to overstate my experience :-))
Re^2: issue with print/join 2 arrays
by juanito23 (Novice) on Apr 30, 2014 at 09:19 UTC

    Hi, I don't have that version of perl so cannot apply that solution so, the "say" is not recognized.

    Any other way to make it work? My current version of perl is v5.8.8

    Thanks!

      In this simple case, just
      sub say { print @_, "\n" }
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-24 00:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found