> hi, > I want to check the status of File handle before > reading/writing to file ? How to do this ? > > like following > > open(FH_IN_FILE, ">file.txt"); >
Which itself is a bad idea, always check that the open succeeded in the first place, open FH_IN_FILE, ">file.txt" or die "Can't open file for writing: $!"; > # This statement is executed by some other function > close(FH_IN_FILE); > Iffy, but ok. > > print FH_IN_FILE "SOME DATA"; > > here before writing to file, i want to check the > status of FH_IN_FILE..(whether file is opened or > closed ) > perldoc -f fileno Is about the only way to check (IIRC). The only way to know whether a file can really be written to is to try and catch any errors that occur. > Thanks > http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>