Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: problem in output

by davorg (Chancellor)
on Jun 29, 2009 at 14:16 UTC ( [id://775686]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://775686]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-16 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found