Roots, dirs and files. An instance script might set
$web_root C:/www $domain_root domain
A config file might have
docroot docroot art_root articles pic_root pics
A base class could have helper methods/assessors for each of the “roots”
Sub docroot{ my $self = shift; my $cnf = $self->cnf; return join( q{/}, $cnf->param(q{$web_root}), $cnf->param(q{$domain_root}), $cnf->param(q{docroot}), ); } sub art_root { my $self = shift; my $cnf = $self->cnf; return join( q{/}, $self->docroot, $cnf->param(q{art_root} ); }
A dir, is a xxx_root, and possibly one or more dir names. A file is a dir with a file name on the end.
my $article_file = join( q{/}, $self->art_root, $art_dirname, $art_filename, );
Anything that needs to be in an html page is $href and $src etc.

What’s wrong with path? Take a selection of core modules:

File::Basename - Parse file paths into directory, filename and suffix.
File::Path - create or remove directory trees
File::Spec - portably perform operations on file names

I find it confusing to keep on top of what a path is in the different contexts. Throw base and suffix into the mix and I’m rereading the docs again for the umpteenth time. File::Spec’s abs2rel talks about $base and $path. And where did those trees come from? And what do you do with a suffix list?

I would use these modules more if I didn’t get into such a tangle. I invariably have helper methods with names that better fit the conventions I’ve outlined e.g. mkdir.

While far from perfect everything has been a lot smoother since banning path.

A plague on paths!

How do monks manage to avoid such confusion?

update: fixed the join syntax
update2: fixed the links


In reply to File system nomenclature. Death to path! by wfsp

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.