Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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:

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
Node Status?
node history
Node Type: perlquestion [id://539712]
Approved by marto
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-11-20 13:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (286 votes). Check out past polls.

    Notices?