Gotta agree with serf here. It's not about whether or not it's expensive or creating another process for one routine that you would want to do.

It's more about practicing good programmer judgment when it comes to writing your code. Would you make system calls for everything you could (like, opening and reading in files, truncating files, moving files, parsing files) in a 3000-5000 line perl script or module you'd created? I doubt it. So why, for the love of god would you promote doing this simple routine with a system call as well. It's just poor programming practice.

Serf has decidedly better points than you do about how to write this perl routine and why you would do it his way.

And yes, there are several problems with using external binaries that are outside of perl to perform routines for your program.

1. Sometimes they will simply not port from one OS to another, talk about waste of valuable programmer time. You would need to re-write your code for every possible OS diference, if needed.
2. They can exercise a larger tax on system resources due to process spawning. Especially if this is the route you're going to take with large pieces of code. But, with complex pieces of code you want to be making very few system calls, if any at all. You may quickly find all of your spawned processes out of control.

Lastly, while I don't promote putting in code simply for the sake of bloating your code with nonsensical information and handlers, if you're measuring your code by the number of lines of code you're producing, you're doing it wrong.

You can write the same function many different ways, and while one way may take up 'less' space, it's almost certain to not have enough error handling and comments.

I've never posted on Perl Monks, and I deeply appreciate all of the great folks who come out here and give freely their knowledge. But, I simply refuse to stand idly by and allow this to be the last comment on this thread as if it's the right thing to do.

Peace.

In reply to Re^5: How to build system calls using '=>' by Anonymous Monk
in thread How to build system calls using '=>' by loris

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.