in reply to Printing Output in different way

Due to their inner workings, hashes don't return the entries in the order you entered them (or only by accident).  If the ordering matters, you can use the Tie::IxHash module.

#!/usr/bin/perl use strict; use warnings; use Tie::IxHash; tie my %hash2, "Tie::IxHash"; %hash2=( a => "apple", b => "boy", c => "cat" ); my @keys=keys %hash2; foreach my $s (@keys) { print "$hash2{$s} "; } __END__ $ ./838968.pl apple boy cat

Replies are listed 'Best First'.
Re^2: Printing Output in different way
by sarshads (Novice) on May 07, 2010 at 23:07 UTC
    Thanks. It works the same as defined in hash.