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

relative paths in catalyst

by holli (Abbot)
on Mar 28, 2006 at 14:58 UTC ( [id://539712]=perlquestion: print w/replies, xml ) Need Help??

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

Brethren,

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 (myApp.pm) is. How can I find this directory?

Update:
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'?

    --Frank

    update: s/base/home/

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


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

        --Frank

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://539712]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-19 09:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found