in reply to Re: Call subroutine of main namespace from package in Plack
in thread Call subroutine of main namespace from package in Plack

Hi choroba, I have a main script app.psgi, inside I have several modules, modules in my local folder like module1.pm, module2.pm, etc

This modules have own functions.

In the app.psgi I have anothers functions relation to router engine urls, to dispach content according to url.

My target is set a value or get a value from main script (app.psgi) and pass that value to all modules, and retrieve the value from module via the function set in main script.

* To do this I can pass a function value to another function.
* I can create a our variable
* I can used db to retrieve data

But I want to avoid the above list, that's why the title of this thread.

  • Comment on Re^2: Call subroutine of main namespace from package in Plack

Replies are listed 'Best First'.
Re^3: Call subroutine of main namespace from package in Plack
by choroba (Cardinal) on Apr 11, 2018 at 15:25 UTC
    I don't understand. A module doesn't know who calls it, it can't make any assumptions about its caller's namespace and capabilities. The contract is defined by arguments and the returned value. If you need a function called in the main program and in the modules, move it into a new module and properly use it everywhere.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,