programming-examples/perl/Hash/Loop through an associative array.pl

10 lines
284 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
while(<>) {
chop;
($Header, $Value) = split(/:/,$_,2);
$Value =~ s/^\s+//; # remove trailing whitespace
$Heading{$Header} = $Value;
}
foreach $Head (sort keys %Heading) {
print "$Head --> $Heading{$Head}\n";
}