P is for Practical | |
PerlMonks |
Re: Is this the most elegant way to code directory lookup?by Hue-Bond (Priest) |
on Sep 29, 2006 at 14:12 UTC ( [id://575531]=note: print w/replies, xml ) | Need Help?? |
Some comments: unless (-d $srcdir && -d $destdir ) It's better not to use unless, unless for simple conditionals ;^). opendir(INDIR,$srcdir) || die Better use lexical filehandles. Also, I don't like to use parentheses, it makes the code more perlish: opendir my $indir, $srcdir or die "blah: $!";unless (-d || $_ eq "." || $_ eq "..") { Same as above. Quick, what does this do? unless ($bar =~ /bar/ or $baz !~ /qux/ and defined $undef)`tar -cz $_ -f $_.tar.gz`; Use backticks when you are going to use the output of the command. This is not the case, so you better use system. Update: Oh, there's a recent thread about unless, be sure to check it out. --
In Section
Seekers of Perl Wisdom
|
|