DarthFredd has asked for the wisdom of the Perl Monks concerning the following question:
I wrote the second implementation because I thought it would be cleaner. Is it? Given the choice, which one would you use? Every opinion shall be gratefully recieved.use File::Find; my $ext = "dat"; my $nom = 0; find ( \&ripper, @ARGV) ; sub ripper { ## First implementation unless(s/\.$ext$//i) {return;} my $file = $_; #using $_ screws up grep $nom += unlink(grep(/\Q$wang\E\.(?!$ext)/, glob("*")),"\n"); } sub ripper2 { ## Second implementation my $file = $_; return unless(s/\.(?!$ext)$//i); my $priority = $_ . $ext; if(-e $priority && !-d $priority) { $nom += unlink $file; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Best programming practice
by Sidhekin (Priest) on Oct 28, 2007 at 22:15 UTC | |
by KurtSchwind (Chaplain) on Oct 30, 2007 at 14:19 UTC | |
Re: Best programming practice
by jdporter (Paladin) on Oct 29, 2007 at 13:06 UTC | |
Re: Best programming practice
by tuxz0r (Pilgrim) on Oct 30, 2007 at 03:59 UTC |