Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??


my @recurse_ignored = $f->list_dir('/dir/', '--recurse','--pattern=\.t +xt$'); my @pattern_and_recurse_ignored = $f->list_dir('/dir/', '--pattern=\.t +xt$ --recurse'); my @no_files = $f->list_dir('/dir/', qw/--pattern=\.txt$ --recurse /);

I would suggest a different notation instead, to use bash "--longname-option" notation inside perl looks ugly (in my opinion)

my @array = $f->list_dir('/home/moo/','--pattern=\.txt$', '--recurse', '--files-only');

I propose this form instead for the same line:

my @array = $f->ls(files, '/home/moo/','\.txt$', 0);

Much easier to write, read and understand, isn't?

list_dir is not a bad name at all, but if you want to obtain a list of files, to use a function named list_dir can sound a little strange

the third argument optional (an integer, or even a range like 1..3) could be equivalent to find -maxdepth num. Recurse should be the default probably, cause you don't need to load a full perl module to do the same job of opendir, readdir in more lines (or when you can simply could wrote `ls *.txt` for this). You expect to be rewarded with the possibility to do something more sophisticated (like to search only for four levels of subdirectories, or in the third subdir) when you take the extra effort to load a module.

I would suggest also to avoid to write "my ($var) = x" in the documentation when you can write simply "my $var = x". The first idea suggests a list context for the vars, for both $scalars and @arrays, and again seems a little more difficult to read.

In reply to Re: Seeking your opinions on proposed patch to File::Util by pvaldes
in thread Seeking your opinions on proposed patch to File::Util by Tommy

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (8)
    As of 2018-06-20 14:14 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (116 votes). Check out past polls.