Hypnotoad and main namespace

101 Views Asked by At

How to handle the main namespace under the Hypnotoad ?

I have this small server:

#!/usr/bin/perl

use Modern::Perl;
use Mojolicious::Lite;

use extmod;

sub hello
{
  say "hello";
}

get "/" => sub
{
  my $c = shift;
  extmod::put();
  $c->render(text=>"ok");
};

app->start;

...and this module:

use Modern::Perl;

package extmod;

sub put
{
  say ">>put:";
  ::hello();
}

1;

A subroutine in a module tries to call a sub in the main namespace;

This works ok under the standard mojo server. But not under the Hypnotoad:

put: [Tue May 30 14:20:37 2017] [error] Undefined subroutine &main::hello called at extmod.pm line 8.

Is it a feature? How to see global namespace in the module?

0

There are 0 best solutions below