[Dancer-users] Undocumented bug or feature

Oleg A. Mamontov oleg at mamontov.net
Wed Jun 22 21:12:58 CEST 2011


Dancer manual (pod) tells us about `path` function:
"Concatenates multiple paths together, without worrying about the underlying operating system".

But unfortunately this isn't true :(
In reality &Dancer::path is &File::Spec::catfile wrapped by &Cwd::realpath.

And &Cwd::realpath is worked with BSD realpath (3) semantic:
"All but the last component of a pathname must exist when realpath() is called."

Assume that '/tmp' directory is exists and empty.
Then this Dancer application code:

  my $x = path "/tmp","nonexistent";
  my $y = path "/tmp","nonexistent","foo";

will assign "/tmp/nonexistent" to $x, but undef to $y.

This behavior may be slightly unexpected :)
So if you create variable with nonexistence path you may get defined or undefined string
depending on missing subdirectories number.

I am not sure what's the best, but (imho) ones should be fixed: Dancer pod or Dancer::path :)

Oleg A. Mamontov

mailto:  oleg at mamontov.net

jabber:  lonerr at charla.mamontov.net
icq uin: 79-521-617
cell:    +7-903-798-1352

More information about the Dancer-users mailing list