Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: 'unlink' seems to not work correctly ...

by gmargo (Hermit)
on Dec 02, 2009 at 20:17 UTC ( [id://810675]=note: print w/replies, xml ) Need Help??


in reply to 'unlink' seems to not work correctly ...

You have a precedence problem with the unlink. Since unlink is a list operator and not a unamed unary operator, the statement

( -l && !-e && unlink "$File::Find::name" || croak "Warning: couldn't unlink $File::Find::name:$OS_ERROR\n" +) unless $param{test};

actually binds as

( -l && !-e && unlink ("$File::Find::name" || croak "Warning: couldn't unlink $File::Find::name:$OS_ERROR\n") + ) unless $param{test};

which is certainly not as you intended. I suggest you add explicit parentheses to the unlink. You could also change the "||" to "or" but parentheses are always clearer. Like this:

( -l && !-e && unlink("$File::Find::name") || croak "Warning: couldn't unlink $File::Find::name:$OS_ERROR\n" +) unless $param{test};

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2024-04-23 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found