Hello everybody, my code below should read in data from a file info.txt into a hash, the sub print_hash should print all hash-elements. actually it only prints the last key-value-pair. Does anybody see the mistake?Thank you for your help!!!
Greetings Habi use strict; my %hash=(); &print_hash(); sub read_in { open(FILE, "info.txt") or die "Die Datei konnte nicht geoeffnet werden: $!\n"; while (my $line = <FILE>) { (my $lastname, my $rest) = split ' ', $line, 2; my @fields = split ' ', $rest; $hash{$lastname} = [ @fields ]; } my $hash = \%hash; return $hash; close FILE; } sub print_hash { my $new_hash = read_in(); foreach my $key (keys %$new_hash) { print "$key @{$new_hash->{$key}}\n"; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]