There is usually more than one way of doing things, and one should choose the one that gets the job done easiest without compromising security. :)
If Larry didn't want us to use system() he wouldn't have given it to us...
Your way of doing it does indeed seem more appropriate for that particular job, however, there are a few things to think about:
- That call may not be cross-platform if the program should be run somewhere else. On some platforms it may even give errors, while perls built-in functions should just return quietly on unsupported platforms.
- Make sure noone can put something into $dir from an external source. It is all too easy to execute arbitrary command this way. Don't let it happen to you. :)
So, in conclusion: the built-in functions has a lot of benefits to them, is the benefit of writing a little less code really bigger? I'm not so sure... A fast opendir, readdir, closedir really isn't that bad, is it? :)
You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.