I don't understand the points you're trying to make. To me the "outside world" is everything that the perl script doesn't control. That includes all files you're trying to open.

If it doesn't exist, don't try to open it unless you are wanting to create it

Uhm. Trying to open a file for reading (which is the default mode of open) does not create it under any circumstance.

You also made the assumption that this file was in the "outside world" when that wasn't the case as per robertobouza's latest post

Since robertobouza post was a reply to mine, how could I have known what he was going to reply to me?

Even if it doesn't change in the mean time, there is absolutely no benefit in check its existence before trying to open it. Suppose you want to be thorough, then you'd have to write something like this:

if (!-e $file) { die "'$file' does not exists'; } if (!-r $file) { die "insufficient permissions to read `$file'"; } if (-d $file) { die "`$file' is a directory, not a plain file"; } # and so on

Actually there are error conditions (like out of memory) that you can't know in advance.

Instead you just do open my $handle, '<', $file or die "Can't open `$fil'e for reading: $!"

And even if the file doesn't change in this case, it can't hurt to stop with bad practices now.

. If the file is locally on his machine then just hammering it to see if it works is not the answer...

Why not? I see no reason not just to try it. I hope I illustrated the reasons for doing so (large number of checks necessary; some checks are impossible to do in advance; danger of race conditions)


In reply to Re^4: Error reading line from file: Operation timed out by moritz
in thread Error reading line from file: Operation timed out by robertobouza

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.