in reply to How do monks create paths?

Other people have pointed you to File::Spec->catfile: that's the way to do it for portable code (e.g. something you expect to post to CPAN).

What I do for local, unix-only hackery is: I never include a trailing slash on directories, and always build up new paths with double-quoted strings.

A typical script might look something like this:

use Env qw( $HOME ); use File::Path qw( mkpath ); use File::Basename qw( basename dirname fileparse ); use File::Copy qw( move copy ); my $some_file = shift; my $basename = basename( $some_file ); my $backup_location = "$HOME/backups"; mkpath( $backup_location ) unless -d $backup_location; my $new_file = "$backup_location/$basename.bak"; copy("$some_file", "$new_file") or die "got problems: $!";

My personal opinion is that doing things like this is a win for readability:
my $new_file = "$backup_location/$basename.bak";

Also, note the stack of "use"s at the top... it's hard to do anything The Right Way in perl without leaning on the standard library a lot. These days I use script templates that include a dozen "use"s by default, so I don't have to try to remember what module "fileparse" is hidden inside of, and so on.