in reply to problem in output

for my $logFile ( glob("$logDir/${logPrefix}*") ) { open($log, "<", $logFile) or die "Can't open $logFile for reading."; open(FP_OUT,">total_transactions") or die "cannot create file total_tr +ansactions for writing"; }

This bit looks weird. How many log files do you think you'll be processing? You're opening multiple files on the same filehandle. Only the last one opened will be processed.

And the standard suggestions about adding strict and warnings apply.

--

See the Copyright notice on my home node.

Perl training courses

Replies are listed 'Best First'.
Re^2: problem in output
by namishtiwari (Acolyte) on Jun 29, 2009 at 14:22 UTC
    Hi, There are not less than 10-15 files in a day log and that will be opened through that log handle. Then how can we modify the code to open each file with diffrent handle. And any suggestions about the output coming wrong. Thanks NT
      Then how can we modify the code to open each file with diffrent handle.

      Not sure that's the right approach. The approach I would take would be:

      • for each file
        • open file
        • process file contents
        • close file
      • next file
      And any suggestions about the output coming wrong.

      I strongly suspect that will be fixed once you process all of the files correctly.

      --

      See the Copyright notice on my home node.

      Perl training courses