GrandFather has asked for the wisdom of the Perl Monks concerning the following question:

The following code:

use strict; use warnings; use XML::Twig; use File::Spec (qw/canonpath/); print File::Spec->canonpath ('c:\\x/y\\z/../../p/q\\r.txt');

generates the error:

"canonpath" is not exported by the File::Spec module Can't continue after import errors at noname.pl line 5 BEGIN failed--compilation aborted at noname.pl line 5.

If I remove (qw/canonpath/) or swap the order of the two use lines the script behaves as expected.

Is this something subtle, a curious interaction between the two modules, or a bug in one or both of the modules?


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re: Module order bug - XML::Twig and File::Spec
by diotalevi (Canon) on May 18, 2006 at 21:45 UTC

    File::Spec doesn't export anything. You should be surprised you don't get the error normally. Use File::Spec::Functions if you want to import canonpath.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊