http://qs321.pair.com?node_id=703403

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