in reply to 2D arrays & mo' better blues

It doesn't print what each x,y coordinate is set to, but it does the same as your code:
use strict; my @alpha = ("a".."z"); my @outtie; # INPUT push @outtie, [ @alpha ] for @alpha; #OUTPUT print join(" ", @{$_}), "\n" for @outtie;

<golf>
@_=(['a'..'z'])x26; print"@$_\n"for@_;
</golf>
note to chipmunk Yes, that's true, but note the <golf> tags... :)

ar0n ]

Replies are listed 'Best First'.
Re: Re: 2D arrays & mo' better blues
by chipmunk (Parson) on Jun 06, 2001 at 23:05 UTC
    @_=(['a'..'z'])x26;
    Careful! That creates @_ as a list of 26 references to the same array. If you change an element in any one of the rows, you'll have changed that element in every row.
    push @outtie, [ @alpha ] for @alpha;
    This snippet from your expanded solution is the preferred way to avoid this problem.