Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How do I tell if a handle is open for writing?

by jZed (Prior)
on Nov 07, 2005 at 16:40 UTC ( [id://506419]=note: print w/replies, xml ) Need Help??


in reply to How do I tell if a handle is open for writing?

Well I may be a member of the idiots' club along with you, and this certainly isn't pretty, but is there a reason this wouldn't work?:
eval { my $pos = $fh->tell; $fh->print('1'); $fh->seek($pos); }; my $ready_for_writing = ($@) ? 0 : 1;
update please ignore this and listen to Zaxo :-)

Replies are listed 'Best First'.
Re^2: How do I tell if a handle is open for writing?
by Aristotle (Chancellor) on Nov 07, 2005 at 16:44 UTC

    You mean other than that it clobbers some content in the file? :-)

    Makeshifts last the longest.

      If this was worth salvaging, I could add in a seek() before the original tell to avoid that problem. But since it's crap anyway, I won't bother :-).
Re^2: How do I tell if a handle is open for writing?
by VSarkiss (Monsignor) on Nov 07, 2005 at 16:51 UTC
      I did that once. I wouldn't recommend it to anyone -- it tends to make your mother a little crazy...

      --DrWhy

      "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-28 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found