in reply to First Value in hash
"How do I make a single step?"
"You start walking and then stop after the first step."
foreach $key (sort(keys %in)) { print MAIL "\t", $key, " = \t", $in{$key}, "\n"; last; } close MAIL;
Or, as an approach that is a bit more verbose yet without the loop:
my @keys = sort keys %in; print MAIL "\t", $key[0], " = \t", $in{$key[0]}, "\n";
Or, as an approach that is a bit more transparent and doesn't use the array:
(my $first) = sort keys %in; print MAIL "\t", $key, " = \t", $in{$key}, "\n";
|
|---|