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

In reply to Re: System vs modules by mikeraz
in thread System vs modules by uksza

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.