Search code examples
pathnameperlfile-find

Why is File::Spec dropping './' on files in sub directories?


File::Spec is a core module to "portably perform operations on file names". This behavior makes perfect sense to me,

# returns ./foo
File::Spec->catfile(".", "foo");

However, this has my mind boggled.

# returns foo/bar
File::Spec->catfile(File::Spec->catfile(".", "foo"), "bar");
File::Spec->catfile("./foo", "bar");

For a library that supposed to standardize this stuff, why is my ./ gone? Is there a reason for this behavior?

Just weird to have this returned,

CP-JobApp/t/lib/Testing.pm
CP-JobApp/t/pod.t
CP-JobApp/t/find.t
./h
./problem1.pl

Is it normal to post-process file names the module returns?


Solution

  • File::Spec::Unix canonizes the directory part of the path.

    Why doesn't it canoninize the whole path (so that catfile('.', 'file') produces file)? No idea. This seems like an oversight to me. Feel free to file a bug report.