Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How to override a "file test" operator

by Marshall (Canon)
on Mar 10, 2012 at 05:52 UTC ( [id://958838]=note: print w/replies, xml ) Need Help??


in reply to How to override a "file test" operator

I am still on 5.10.x, but from reading the 5.14 documentation overload, it appears that it is possible to overload the file test operators, although its not easy to do.
File tests The key '-X' is used to specify a subroutine to handle all the filetest operators (-f , -x , and so on: see -X for the full list); it is not possible to overload any filetest operator individually. To distinguish them, the letter following the '-' is passed as the second argument (that is, in the slot that for binary operators is used to pass the second operand). Calling an overloaded filetest operator does not affect the stat value associated with the special filehandle _ . It still refers to the result of the last stat, lstat or unoverloaded filetest. This overload was introduced in Perl 5.12.
I sometimes use the _ filehandle in Perl 5.10. I take this 5.14 description to mean that this feature won't work if you overload the file descriptors to follow Win32 sym links. I think that what you want to do is possible although not easy.
  • Comment on Re: How to override a "file test" operator

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-23 20:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found