in reply to filehandles and setuid

as an aside, in older versions of perl (as recent as 5.005_03,) using $! with \n causes different results than $! alone. perhaps you'll get a different (better) error if you strip off the newline. i don't know if this is still the case, but i never use newlines with $! anymore.

~Particle ;Þ

Replies are listed 'Best First'.
Re: Re: filehandles and setuid
by Fletch (Bishop) on Apr 10, 2002 at 14:10 UTC

    I think what you're alluding to is the fact that die, not $! (although die "... $!\n" is the common idiom), behaves differently if the message passed has a trailing newline or not. If it doesn't, the location the die occured at will be appended; if the message does end with a newline it's printed verbatim. I tend to use the with-a-newline for error messages that users may see, and without-newline in modules where the extra location information is of more use.

    See perldoc -f die and perldoc Carp for more information.

    Addendum: warn has similar behavior as well.

$! with and without \n
by RMGir (Prior) on Apr 10, 2002 at 13:06 UTC
    Wow, particle, really??

    That is quite strange. Not that perl hasn't had other strange quirks, mind you... Do you have a pointer to more details?

    I'm curious about this one, it sounds like a problem that could be hard to diagnose if you don't know about it.

    Supersearch won't help, since $! and \n are both unfortunately shorter than 4 characters...
    --
    Mike

      lo, i have searched the deep recesses of my mind, and have found... nothing.

      neither Super Search nor Google have aided me. luckily, Fletch has come to my rescue! his response (below) is right-on. die behaves differently, not $!

      ~Particle ;Þ