perumal has asked for the wisdom of the Perl Monks concerning the following question:
The above code reads the contents from a file and puts them in a hash.i want to reuse this hash in another method ..how do i do that?sub main{ my $path; my @paths; my %alarm_details; my @alarm_details; @paths = </TELECOM_PROJ_MAIN/sas/tmp/t*>; #giving the file path foreach $path(@paths){ %alarm_details = {}; open(LOG,"<$path") || die "can't open log "; $alarm_details{filepath} = $path; while (<LOG>) { /^(.*)=(.*)$/; $alarm_details{ $1 } = $2 if ($1); } push(@alarm_details,\%alarm_details); } return Dumper(@alarm_details); }
Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
2006-06-12 Retitled by Corion, as per Monastery guidelines
Original title: 'hashes'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reuse hashes in another method
by Zaxo (Archbishop) on Jun 12, 2006 at 09:38 UTC | |
|
Re: reuse hashes in another method
by Samy_rio (Vicar) on Jun 12, 2006 at 09:33 UTC | |
by Joost (Canon) on Jun 12, 2006 at 09:40 UTC | |
|
Re: reuse hashes in another method
by McDarren (Abbot) on Jun 12, 2006 at 09:46 UTC |