Hello Thenothing,
I am not familiar with PSGI/Plack but I read your question Perl - Call subroutine of main namespace from package and I think you are looking for something like that:
main.pl
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Mypackage; sub callingTest { my $object = new Mypackage(); return [ 200, [ "Content-Type" => "text/html" ], [ $object->test() + ] ]; }; print Dumper callingTest(); __END__ $ perl main.pl $VAR1 = [ 200, [ 'Content-Type', 'text/html' ], [ 'from test' ] ];
Mypackage.pm
package Mypackage; sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; } sub test { return "from test"; } 1;
Hope this helps, BR.
In reply to Re: Call subroutine of main namespace from package in Plack
by thanos1983
in thread Call subroutine of main namespace from package in Plack
by Thenothing
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |