Loop through an associative array : Hash Loop « Hash « Perl






Loop through an associative array

   

    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";
    }

   
    
    
  








Related examples in the same category

1.Iterate hash
2.Loop through an associative array While loop
3.Looping Over A Hash
4.Using foreach loops with hashes
5.While loop and hash key value pair
6.Using while and each function to output value in a hash