in reply to Re: Perl Style: About error messges opening files
in thread Perl Style: About error messges opening files

A line number in the program that figured out the file wasn't there doesn't do much for me.

Well, my logging system automatically graduates die into confess so i actually get a full back trace. And here at least usually the reason a file isnt there is becuase somebody told the program to operate on something that it shouldnt. :-) Rarely is it due to a failure on the upstream side.

BTW, the problem I have with something like what you describe here is that it wont be able to show the filename involved will it? At least not without overriding open.


---
demerphq

    First they ignore you, then they laugh at you, then they fight you, then you win.
    -- Gandhi


Replies are listed 'Best First'.
Re: Perl Style: About error messges opening files
by Abigail-II (Bishop) on Apr 27, 2004 at 11:53 UTC
    BTW, the problem I have with something like what you describe here is that it wont be able to show the filename involved will it?
    Since about all pdie and perror do is tack "$!\n" to the die or warning message, I fail to agree.
    open my $fh => $file or pdie open => $file;
    might print "open /ect/passwd: No such file or directory".

    Abigail

      Since about all pdie and perror do is tack "$!\n" to the die or warning message, I fail to agree.

      Ah. Yeah. Good idea and point. :-) Might be worthy doing cluck/carp/croak/confess versions as well as the warn/die variants though.


      ---
      demerphq

        First they ignore you, then they laugh at you, then they fight you, then you win.
        -- Gandhi


        Considering that perror and pdie don't print line numbers, carp and croak versions would not add anything. Also, I'd expect terseness when perror or pdie are used - not something I associate with the stack traces of cluck and confess. So, I don't see much added value in adding c-variants. But anyone could subclass it to PError::Carp, ;-).

        Abigail

      The purpose of perror is largely to explain ERRNO, same as $!. We don't need a module or function for this. Many C programmers who love perror() -- including myself -- get along just fine with $!.
      A reply falls below the community's threshold of quality. You may see it by logging in.