in reply to Re^3: Hash Trouble
in thread Hash Trouble

You are right... my blunder. No what I meant about the Hash thing was someone building a hash table for each file. In my case there are multiple files so I would perfer looping through for example the log files from multiple days and make one hash table. This section of code will be used for analysis and once certain peg counts are reached, email the responsible part will the information. Thank you for all of your assistance and words of wisdom, Terry.

Replies are listed 'Best First'.
Re^5: Hash Trouble
by ikegami (Patriarch) on Nov 19, 2004 at 19:09 UTC
    oh! well that's pretty simple, and you have a few alternatives.
    { local @ARGV = ('file1', 'file2', ...); while (<>) { chomp; ... } }

    or

    foreach $filename ('file1', 'file2', ...) { local *RPT; open(RPT, '<', $filename) or die("...\n"); while (<RPT>) { chomp; ... } }

    or

    sub read_log { my ($filename, $analysis_ref) = @_; local *RPT; open(RPT, '<', $filename) or die("...\n"); while (<RPT>) { chomp; ... if (exists($$analysis_ref{$key})) { $$analysis_ref{$key} .= $msg; } else { $$analysis_ref{$key} = $msg; } ... } } my %analysis; read_log($_, \%analysis) foreach ('file1', 'file2', ...);