On 3/21/06, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: > Jeff Pang wrote: > >> So why wouldn't you redirect STDOUT and STDERR to this file too? Many > >> other Perl's errors, like division by zero, are not handle via die or > >> warn. And these messages are printed out even if encountered in an eval. > >> > > > > When operating the files (including opening and writing and closing),you > > have more risks to 'die' than writing to '/dev/null',isn't it? > > > > -- > > Jeff Pang > > NetEase AntiSpam Team > > http://corp.netease.com > > > > If you redirect a file handle to an already existing one, there are far > fewer things that can go wrong. In fact, when you open a regular file > the most common errors are: file not found, permission denied, and disk > full. If you have a real hardware problem, your program might be the > first to find it but you will have programs failing all over the place. > Hardware errors are usually fairly obvious. > >
this is getting OT, but it depends on the hardware that's failing. Memory errors are notoriously difficult to pinpoint, as they're often intermittent, at least as first. Many disk errors start out intermittent, too, although those situations tend to detriorate rapidly. As for simply redirecting STDERR, most people don't really want to do this with a daemon. If you're using strictures and warnings, you expect many daemons to produce hundres, possibly thousands, of lines of warnings, depending on the purpose of the daemon, how busy it is, and how long-lived it is. Do you really want to log every "use of undefined value" in match and/or string concatentation error? I know I don't. Nor do I want to check everything I use for definedness. If it's there, print it. If it's not, print the rest of the line, or let the match fail, or whatever. Redirecting STDOUT is a more common idiom, but not always a good idea, either, because you may very well want to use cron, and get some useful info mailed. Sure, for simple situation, you can just redirect the default file handles, but I'm certainly an advocate, personally, of using a logging facility (either RYO or a syslog interface) to log, using that interface to write both the data and the errors I'm interested in (which may be differnt from what Perl sees fit to write to STDERR) to the appropriate files, and redirecting STDERR to /dev/null so it doesn't clutter up either the console or the log files with non-critical errors. unless I'm debugging, of course. -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!