in reply to Call subroutine of main namespace from package in Plack
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Call subroutine of main namespace from package in Plack
by Thenothing (Sexton) on Apr 11, 2018 at 14:56 UTC | |
by stevieb (Canon) on Apr 11, 2018 at 15:07 UTC | |
by thanos1983 (Parson) on Apr 11, 2018 at 15:11 UTC | |
by Thenothing (Sexton) on Apr 11, 2018 at 15:34 UTC | |
by thanos1983 (Parson) on Apr 11, 2018 at 15:53 UTC |