Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: [threads] Open a file in one thread and allow others to write to it

by Gangabass (Vicar)
on Nov 16, 2009 at 11:38 UTC ( [id://807419]=note: print w/replies, xml ) Need Help??


in reply to Re: [threads] Open a file in one thread and allow others to write to it
in thread [threads] Open a file in one thread and allow others to write to it

I call it log but this is just text file containing data parsed from Web page. And it's name format is defined by the user in the config file.

  • Comment on Re^2: [threads] Open a file in one thread and allow others to write to it

Replies are listed 'Best First'.
Re^3: [threads] Open a file in one thread and allow others to write to it
by BioLion (Curate) on Nov 16, 2009 at 13:16 UTC

    Why not have a shared variable which you write the 'log' to, say an array which holds the information for each line entry, and a thread which keep an eye on the size of the shared array and dumps it out when it hits whatever size you want and resets it.

    This way you don't need to worry about shared filehandles, only a shared in-memory variable ( IPC::Sharable seems to be the usual way of doing this ), and you have separated the 'logging' function from the 'collection' function.

    Just a something something...

Log In?
Username:
Password:

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

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

    No recent polls found