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

Re^2: M3U Playlist Generator

by Anonymous Monk
on Jul 01, 2012 at 21:28 UTC ( #979330=note: print w/ replies, xml ) Need Help??


in reply to Re: M3U Playlist Generator
in thread M3U Playlist Generator

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 : $! ";


Comment on Re^2: M3U Playlist Generator
Select or Download Code
Replies are listed 'Best First'.
Re^3: M3U Playlist Generator
by Soul Singin' (Initiate) on Jul 02, 2012 at 05:12 UTC

    Below is my rewritten version which does not depend on File::Find

    Why?

    Because I cannot understand the documentation. I'll take a look at your example and keep playing. Thanks!

    $inpath can be file ( use -f or -d inestead of -e, since both -f and -d imply -exist )

    Good point! -d would be best because the $inpath should be a directory.

    $inpath could contain glob metacharacters

    Doh! I did not even think of that ... because on my system it will not!

    3 argument open is better than two

    Old habits are hard to break.

    Thanks! Your comments have been very helpful.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://979330]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (16)
As of 2015-07-07 22:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls