Hi Julian On Mon, Sep 24, 2007 at 10:34:59AM +0000, Julian Mehnle wrote: > Ola Lundqvist wrote: > > > `perldoc -f do` says: > > > | If "do" cannot read the file, it returns undef and sets $! to the > > > | error. If "do" can read the file but cannot compile it, it returns > > > | undef and sets an error message in [EMAIL PROTECTED] If the file is > > > | successfully compiled, "do" returns the value of the last > > > | expression evaluated. > > > > > > Thus relying on $! and $@ is officially sanctioned. > > > > I can not see that. It do not say anything about the $! or $@ when the > > expression return true. It only tell that they are set when it returns > > false. > > > > The above statements formalized: > > If X return undef and set $! > > if Y return undef and set $@ > > if Z return $lastexpr > > > > I can not see anything about > > if return true, set $! = 0, set $@ = 0; > > > > It may be so that it do that and I did some test code that verifies > > that. However I do not want to rely on undocumented features too much > > if there are documented features that I can rely on. > > You're right, and it even actually says (in `perldoc perlvar`) that $! > does NOT get set to 0 if there is no failure. Perhaps you could > explicitly set $! to 0 before the do() call, though?
Ok, good to know. > About $@, I'm certain that it gets set to "" if the file could be read and > compiled successfully. Ok that is likely so. > > > I think the "check whether do() returns true" idiom is a remnant from > > > old times when Perl didn't know exceptions ($@). > > > > This is the result of the test code: > > > > Condition return $! $@ > > -------------------------------------- > > Read error undef string "" > > Syntax error undef "" string > > No statements undef "" "" > > last 0 0 "" "" > > last 1 1 "" "" > > > > The "" above could also be undef, but I did not have the time to check > > that now. > > > > But this is from my perl version. In your case for "No statements" the > > value for $! and $@ was ^I. > > Maybe this is a syslog oddity? I've never seen $! or $@ getting set > to "^I" ("\t"), so I don't think this is their actual value. Ahh ^I = \t, then I understand. Yes that is likely a syslog oddity. > > I can provide some testing code to you if you want so we can determine > > the table above for your perl version. > > I doubt it would be any different with Perl 5.8.8, which is what I'm > running. > > Well, we could try setting $! to 0 before the do() call and checking > ($! || $@) afterwards. If that doesn't work, then the debarchiver That could be a solution, yes. I'll check that out. > man-page would have to explain that there needs to be a final, true- > valued statement in every config file. True. I'll come up with a solution. I hope you do not see this log everytime now at least. :) Best regards, // Ola -- --------------------- Ola Lundqvist --------------------------- / [EMAIL PROTECTED] Annebergsslingan 37 \ | [EMAIL PROTECTED] 654 65 KARLSTAD | | http://opalsys.net/ +46 (0)70-332 1551 | \ gpg/f.p.: 7090 A92B 18FE 7994 0C36 4FE4 18A1 B1CF 0FE5 3DD9 / --------------------------------------------------------------- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]