Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by jZed (Prior)
on Nov 07, 2005 at 16:40 UTC ( #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 :-)


Comment on Re: How do I tell if a handle is open for writing?
Download Code
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
Node Status?
node history
Node Type: note [id://506419]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-10-31 05:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (214 votes), past polls