in reply to does a script run via plackup knows where it is?

Maybe, probably–

# app.psgi, cp or mv it around and plackitup. :P use Path::Tiny; my $location = path(__FILE__)->absolute; sub { [ 200, [], ["OHAI $location!"] ] }

Update: I actually think a command line argument or plackup wrapper might be a better choice here. Multiple copies of code is code smell.

Replies are listed 'Best First'.
Re^2: does a script run via plackup knows where it is?
by morgon (Priest) on May 14, 2018 at 16:33 UTC
    Yep, thanks a lot.

    The only thing you need watch out for is that your above $location is actually an object and when you return that from a Dancer2 handler it confuses Dancer greatly.

    But it solves my my need in an already bad-smelling hack, so never mind code-smell...

      That's partly why I quoted it in the example. It stringifies the object. You can, as you probably already found, do $location->stringify too.