Below is my rewritten version which does not depend on File::Find Why?
Comments welcome.
$inpath can be file ( use -f or -d inestead of -e, since both -f and -d imply -exist )
$inpath could contain glob metacharacters
I'm personally not a fan of interactive commands, exit program if file already exists and overwrite not forced ( Getopt::Long ),
$inpath could contain glob metacharacters
if you don't want to recurse, you could write
use File::Find::Rule;
my @files = find( 'file', 'name', qr/\.mp3$/i, 'maxdepth', 1, 'in', $i
+npath );
FWIW, if you need to do path manipulations, Path::Class::Rule is better than File::Find::Rule;
3 argument open is better than two, "or" is better than "||" since it doesn't require extra parens open my($fh), '>', $file or die "can't open '>', $file : $! ";
|