Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

relative paths in catalyst

by holli (Monsignor)
on Mar 28, 2006 at 14:58 UTC ( #539712=perlquestion: print w/replies, xml ) Need Help??
holli has asked for the wisdom of the Perl Monks concerning the following question:


I am writing a Catalyst application, that needs to access several files. Currently I'm doing this by using absolute paths.

Now I would like to use path names that are relative to the directory where the applications main module ( is. How can I find this directory?

When I run the app under mod_perl,
cwd returns "\xampp\apache", $Findbin::Bin returns "\xampp\apache\bin" and $0 returns "\xampp\apache\bin\apache.exe",

holli, /regexed monk/

Replies are listed 'Best First'.
Re: relative paths in catalyst
by LTjake (Prior) on Mar 28, 2006 at 15:49 UTC

    You can use the path_to helper:

    $c->path_to( 'bar', 'foo.txt' );

    See the docs for more info.

    "Go up to the next female stranger you see and tell her that her "body is a wonderland."
    My hypothesis is that she’ll be too busy laughing at you to even bother slapping you.
    " (src)

Re: relative paths in catalyst
by haoess (Curate) on Mar 28, 2006 at 15:17 UTC
    $c->config->{base} $c->config->{home} gives you the path, where YourApp lives. Perhaps you want $c->config->{home} . '/lib'?


    update: s/base/home/

      On my system, $c->config->{base} is empty :(

      holli, /regexed monk/
        O yes, sorry, it's $c->config->{home}.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://539712]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2018-05-27 20:02 GMT
Find Nodes?
    Voting Booth?