Hello wise ones,

I need to know if there's any possible way to override a file test operator. Specifically, I need to override the -l file test. This is an example:

my $isSymlink = -l "path/to/file";

Now, before you answer "why in earth would you even want to do that?", I explain. Perl implementation on Win32 doesn't implement the CORE functions symlink, readlink and file-test "-l", based on the wrong legacy idea of Windows not supporting symlinks. NTFS implements complete symlink functionality although it wasn't very well documented until Windows Vista was released.

I'm trying to run some modules that rely a lot on the symlink Perl functionality and cannot work on Win32 only because of these functions/operator not being implemented.

I already managed to override the CORE functions symlink and readlink in any namespace by the use of a overriding module I created and the use of the special file site/lib/sitecustomize.pl. Both functions work great and return the same result you would expect on unix. But I cannot find a way to do the same to the "-l" file test.

Is there someone here with that depth of knowledge of Perl tricks/secrets? I hope so!

Thanks in advance for any advice. :-)

Francisco

In reply to How to override a "file test" operator by Zarabozo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.