Hi perumal, Try This,
use strict; use warnings; use Tie::IxHash; use Data::Dumper; my ($alarm_details) = &main(); print Dumper @$alarm_details; sub main{ my @alarm_details; my @paths = qw(c:/test/sample.xml c:/test/sample1.xml); #giving th +e file path foreach my $path (@paths){ my %alarm_details; #Declare Each time instead of setting nu +ll value tie %alarm_details, "Tie::IxHash"; #for Hash in order open(LOG,"<$path") || die "can't open log "; $alarm_details{$path} = $path; while (<LOG>) { chomp; /^(.*)=(.*)$/; $alarm_details{ $1 } = $2 if ($1); } push(@alarm_details,\%alarm_details); } return \@alarm_details; }
Updated : Thanks Joost
Regards,
Velusamy R.
In reply to Re: reuse hashes in another method
by Samy_rio
in thread reuse hashes in another method
by perumal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |