in reply to reuse hashes in another method
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reuse hashes in another method
by Joost (Canon) on Jun 12, 2006 at 09:40 UTC |