Problem description:
when using "-e" command (see example below) to check if file exists, in some cases getting incorrect answer.
While the file actually exists, the "-e" indicates that the file doesn't exists.

Environment:
The file is located in mounted area in NetApp server.
Perl version 5.10.1.

# Scenario 1, example of the problem: my $is_file_exists = 1; my $db_path = $ST_DB_PATH.$db_name; unless (-e $db_path) { print "The file doesn't exist\n"; $is_file_exists = 0; }
In some cases, the result of Scenario 1 is $is_file_exists=0
while the actually file exists.
# Scenario 2, example of workaround that solves the problem: my $is_file_exists = 1; my $db_path = $ST_DB_PATH.$db_name; # Adding cat command to solve the "-e" problem `cat $db_path > /dev/null`; unless (-e $db_path) { print "The file doesn't exist\n"; $is_file_exists = 0; }
Workaround description:
Before using "-e" command, using system command: "cat <file>".
When calling "-e" command after "cat" the "-e" works as expected.

I use the "cat" as a workaround, I can't use it in the entire code.
Does someone faced such a problem and found solution?
Do you think this problem is related to the Perl or to the native platform or to the NetApp environment?


In reply to File Existence using "-e" not always working by IL_bullfinch

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.