http://www.perlmonks.org?node_id=120822


in reply to Re: Re: opening new file in different directory
in thread opening new file in different directory

Ok. First things first, add some verbosity to your error handling:
open(WRITE,">$file") or die( "Cannot write to $file: $!" );

And then let us know what the whole error is, makes it much easier :)

--
Graq

  • Comment on Re(3):: opening new file in different directory

Replies are listed 'Best First'.
Re: Re(3):: opening new file in different directory
by George_Sherston (Vicar) on Oct 23, 2001 at 19:49 UTC
    Same error as before, No such file or directory.

    I left out the verbosity because (A) I haven't decided how to do it yet, so not sure what I have to put in my error string (B) $! points me to the line, which is all I need to know for now... and I know it well anyway, alas (C) I didn't want too much wrapping and (D) I guessed that nobody wd be copying my code since it's effectively labelled as broken.

    Still, I know this is one of those points on which the monastery is rightly strict.... /me goes into the dungeon for a moment's mortification.

    § George Sherston
Re: Re(3):: opening new file in different directory
by IraTarball (Monk) on Oct 23, 2001 at 20:48 UTC
    Not to be an ass, but how would this help us? It seems the germane info is in $! not the script name and line number.

    I'm really asking and not trying to fish slap you.

    Ira,

    "So... What do all these little arrows mean?"
    ~unknown

      Look at it again:
      open(WRITE,">$file") or die( "Cannot write to $file: $!" );
      You are missing the point of his request. He wants to see what $file is, in addition to the $! variable. Why? Because the error "No such file or directory" begs the question "What file is the program trying to create, and in what directory?"

      buckaduck

        Goip! Read carefully and ye shall find knowledge.
        Thanks for humoring me. :)

        Ira,

        "So... What do all these little arrows mean?"
        ~unknown