Thread Such (Hash, Array)
(17 answers)
Opened by mikey_b at 2010-03-15 20:26 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 24 25 26 %hash = (); open (AN, $ARGV[0] ) or die "Not Found\n"; open (IN, $ARGV[1]) or die "Not Found\n"; while ($line = <AN>) { chomp $line; ($k, $v) = split / /, $line; $hash{$k} = $v; } while (<IN>) { chomp; push (@text, split /\n/); # warum split, Zeilentrenner ist doch schon "\n" } for $sentence ( @text ) { @word = split / /, $sentence; # wort zu zahl $_=$hash{$_} for @word; # auffüllen push(@word,0) while(@word < 5); print join(','@word)."\n"; } Last edited: 2010-03-16 11:04:25 +0100 (CET) |