Thread Elegante Syntax für Hash-Def (11 answers)
Opened by bianca at 2010-03-27 12:41

bianca
 2010-03-27 12:58
#135349 #135349
User since
2009-09-13
6998 Artikel
BenutzerIn

user image
2010-03-27T11:51:58 esskar
wie benutzt du hash-of-hash und nicht hash-of-array?

Ist unübersichtlich. Meine Werte sind nicht so kurz wie foo und bar.

Ist das hier i.O. oder gibt's Fallen?

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl -w
use strict;
use warnings;
use Data::Dumper;
my %tabelle;
foreach my $line (split /\n/,<<KONSTANTE
foo                             N
bar                             A
KONSTANTE
) {
        $line =~ s/\t\t/\t/g while $line =~ /\t\t/;
        (
                $tabelle{head}{(keys %{$tabelle{head}}) + 1},
                $tabelle{typ}{(keys %{$tabelle{typ}}) + 1},
        ) = split /\t/,$line;
}
print Dumper(%tabelle);
10 print "Hallo"
20 goto 10

View full thread Elegante Syntax für Hash-Def