|Just another Perl shrine|
Re: Seeking your opinions on proposed patch to File::Utilby pvaldes (Hermit)
|on Sep 30, 2012 at 23:47 UTC||Need Help??|
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.