Why use Perl at all? That, to me, is the essence of your question. If your Perl code is a sequence of system calls you could save yourself some grief with a shell script or batch file.
Certainly when you're starting in Perl a construct like $retval = system "logger -t PERLSEZ TIMTOWTDI Rulz!" is a safe and familiar way to get the word out. So (to continue using this example) you can wonder why Tom and Larry bothered to code up Sys::Syslog and what they did to make it worth using. A quick check of the CPAN page shows that you can start by
use Sys::Syslog;
openlog "PERLSEZ", "pid", "LOG_MAIL"; # say it once and let Sys::Syslo
+g remember for the duration, save me some typing later
# add code as needed
Now your program will tag each line of your log message with the string PERLSEZ, include the process ID, and send it all to the mail logging system. Later on your program can syslog "info", "spammer trying dictionary attack blocking $ipaddr";
(an action taken thousands of times a day by my system, but that's a different thread)
Sys::Syslog provides full control over logging. Note that you don't get to specify the facility, which log type, with /usr/bin/logger. Along with the full control your openlog call will set up some global options so you don't have to specify them on each call. Handy. The other Perl replacements for varied system "command [args]" have their unique advantages.
Best of all you get to do both. Use system ...; until you have a frustration with what it won't do for you then investigate what Perl and CPAN have to offer for alternatives. Play with a few, choose the one that floats your boat and implement it.
Be Appropriate && Follow Your Curiosity
|