Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Apparently, realpath( catfile( __PACKAGE__, updir(), 'db' ) ) is producing undef.

Look up and see under what conditions realpath will be undef. Maybe it's being fed undef as one of its arguments?

In any case, what do you really want to do if that value is undef? I'm guessing your logic is that if the directory by that name exists use it, or else use realpath('db'). If it has trouble even figureing out the proposed directory, that is in the same boat, right?

So make it:

unless (defined $db_dir_qfn && -d $db_dir_qfn) {
In any case, perhaps the problem isn't that the code finding the directory behaves any differently, but that -d used to not warn and now it does? It might has simply said "no, that's not a valid directory" when fed undef before. You can look that up in perldelta or just try it on your existing Perl installation.

Note that you can write it more concisely as:

$db_dir_qfn = realpath('db') unless defined $db_dir_qfn && -d $db_dir_ +qfn;
but then again, the test is the important part and maybe it should still go up front:
defined $db_dir_qfn && -d $db_dir_qfn or $db_dir_qfn = realpath('db');
saves the excess bracing.

In reply to Re: Finding files relative to a module by John M. Dlugosz
in thread Finding files relative to a module by hsmyers

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (10)
    As of 2020-01-27 21:00 GMT
    Find Nodes?
      Voting Booth?