Thread hashes of hashes (6 answers)
Opened by hannesPR at 2010-10-01 03:55

Gast wer
 2010-10-01 09:38
#141605 #141605
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl
use strict;
use warnings;

my $x=7;
my $y=10;

# kurze variante:
#my @array=map{[map{'W'}(1..$y)]}(1..$x);

# auführlicher:
my @array;
for my $px (0..$x-1)
{
  for my $py (0..$y-1)
  {
    $array[$px][$py]='W';
  }
}

# hüpsche Ausgabe
printf("     %s\n   +-%s\n", join('',map{sprintf("%02u ",$_)}(1..$y)),'---'x$y);
printf("%02u | %s\n   |\n", $_+1, join('',map{sprintf("% 2s ",$_)}@{$array[$_]}) ) for(0..$#array);


Tut mir Leid ich sehe das Problem nicht, warum muss man irgendwelche ArrayNamen dynamisch erzeugen?
Last edited: 2010-10-01 09:39:47 +0200 (CEST)

View full thread hashes of hashes