Don't use forward or backslashes, instead use
File::Spec or
Path::Class:
use File::Spec; # could also use File::Spec::Functions
my $file_name = File::Spec->catfile(File::Spec->updir, qw/foo bar.txt/
+); # "../foo/bar.txt" on unix
# or
use Path::Class;
# these return Path::Class::File objects which can be used as strings
# and also have some convenient methods ($file->open, etc)
my $file_a = Path::Class->new()->parent->subdir("foo")->file("bar.txt"
+);
my $file_b = file(dir()->parent, "foo", "bar.txt');