I am getting ready to release a script I have written and am currently in the process of removing any of the system dependent coding practices I may have used due to time constraints. This includes using the following block of code:
foreach my $file (`find $dir -type f -name "*.txt"`)
My question is, what is the best method to replace this type of behavior? I have looked at 3 methods so far:
method 1: glob
advantages: built in to perl
disadvantages: ??
method 2: File::Util
advantages: gets both the files and the directories (although for this script I never need the list of directories)
disadvantages:
-does not seem to be a core perl module and I would like to keep the number of non-standard modules to a minimum for ease of use
- longer to code than using glob?
method 3: File::Find
advantages: seems to be a core perl module
disandvantages: ? - longer to code than using glob?
Any advice on what the best practice(s) are for finding files located in a single (known) directory would be great.
Thanks, Mav3067
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.