Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Can't remove directory-Permission denied (knot)

by tye (Cardinal)
on Oct 22, 2012 at 15:02 UTC ( #1000362=note: print w/ replies, xml ) Need Help??


in reply to Re: Can't remove directory-Permission denied
in thread Can't remove directory-Permission denied

return unless /[^.]/;

I'm not unsure that it isn't impossible to avoid not including more negations without having to avoid a lack of not trying.

return if /^\.{1,2}\z/;

The 'return' still represents one implied negation ("don't do the following"). Each additional negation adds the chance for mentally dropping the negation and introducing a bug or wasting too much time getting very confused.

It also doesn't skip directories named "...". :) And, of course, that code is assuming a Unix or Windows file system.

- tye        


Comment on Re^2: Can't remove directory-Permission denied (knot)
Select or Download Code
Re^3: Can't remove directory-Permission denied (knot)
by Lotus1 (Chaplain) on Oct 22, 2012 at 15:59 UTC

    To match '.' don't you need to use '\.' or [.] ?

      Indeed. I had [.] then changed it to \.. I suspect the \ accidentally got dropped when I further updated the regex. Sorry about that. Fixed now. Thanks.

      - tye        

Re^3: Can't remove directory-Permission denied (knot)
by Athanasius (Abbot) on Oct 22, 2012 at 16:42 UTC
    I'm not unsure that it isn't impossible to avoid not including more negations without having to avoid a lack of not trying.

    Clarity itself to a logician, certainly, but — on the offchance that some following along at home might need a little help — let Perl elucidate:

    #! perl use strict; use warnings; my $str1 = "I'm not unsure that it isn't impossible to " . "avoid not including more negations without " . "having to avoid a lack of not trying."; my $str2 = $str1; my %negs = ("not un" => "", "it isn't im" => "it's ", "avoid not including" => "include", "without having to avoid" => "by", "a lack of not" => ""); # Collapse double negatives while (my ($key, $value) = each %negs) { $str2 =~ s/$key/$value/g; } # Remove extra spaces $str2 =~ s/\s+/ /g; # Display the translation print "$str1\n\n-->\n\n$str2\n";

    (Is there anything Perl can’t do?)

    Athanasius <°(((><contra mundum

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2015-07-03 21:07 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 (56 votes), past polls