Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Generate unique file handles

by alih110 (Novice)
on Aug 20, 2008 at 08:23 UTC ( [id://705445]=note: print w/replies, xml ) Need Help??


in reply to Re: Generate unique file handles
in thread Generate unique file handles

I have not yet tried it. Following is the issue faced with a fixed file handle name => Since the perl module is called in parallel through LSF, suppose one process finishes reading the file and closes the filehandle while another process is still reading the file, this file handle also gets closed and it never reads the file completely. Thats why I wanted to have unique file handle names. Can I try $fh_$$ so that it generates a unique file handle with process id?

Replies are listed 'Best First'.
Re^3: Generate unique file handles
by moritz (Cardinal) on Aug 20, 2008 at 08:28 UTC
    If LSF starts a new process for each job (and only in this case $$ will actually help you) it's not an issue at all, because perl variables aren't shared across processes. In this case you can even use bare word file handles, although I don't recommend them.

    Even if it uses perl threads, there's no need to worry because variables aren't shared by default.

    (As a side node when you think of a variable variable name, use a hash instead. So instead of the non-working $fh_$$ you'd use my %handles; $handles{$$} = ... instead. But as said above, no need here).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-26 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found