Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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/

Comment on relative paths in catalyst
Select or Download Code
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2015-11-28 12:08 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (741 votes), past polls