[Catalyst] cross-platform locations

Jason Kohles email at jasonkohles.com
Sun Feb 26 17:02:14 CET 2006


On 2/24/06, Carl Franks <fireartist at gmail.com> wrote:
> On 23/02/06, Jason Kohles <email at jasonkohles.com> wrote:
> >
> > This change would break a lot of currently working code....
> >
> > From the documentation for lib.pm:
> >
> >        In order to keep lib.pm small and simple, it only works with Unix
> >        filepaths.  This doesn't mean it only works on Unix, but non-Unix users
> >        must first translate their file paths to Unix conventions.
> >
>
> Ok, that's wierd, that says it only works with unix filepaths (forward
> slashes), yet I've just confirmed that using backslashes does work on
> my machine.
> I won't loose sleep about it though, as long as non-unix platforms
> will work with forward slashes, that's fine.
>
> What about the idea of using "File::Spec->updir()" to replace the ".." though?
>
> maybe,
> use lib sprintf "%s/%s/lib", $FindBin::Bin, File::Spec->updir();
>
What 'use lib' actually does is just push the values you give it onto
@INC.  Which means it works with any paths that will work on your
machine.  However, the documented interface is the only one that you
can expect to continue to work.  If you read through the code in
lib.pm, there are a lot of comments about things that may change in
the future (for example, on Mac OS File::Spec is used, and there is a
comment that in the future it may be used for other platforms as
well).  There are a lot of things you can do that may work on your
machine, but if you stick to the documented interface, then you won't
break it for other people without knowing.

I would recommend sticking with the documented interface, there is
nothing wrong with the way it works now.  If you really want to change
something about it, my suggestion would be to remove the ..
altogether, so you get paths that look like /path/to/my/project/root
rather than /path/to/my/project/script/../root...

--
Jason Kohles
email at jasonkohles.com - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire



More information about the Catalyst mailing list