-1

I read this bug but I can't figure out how can I use my module in a perl application on the opeshift platform.

This is my module in ./libs/MyModuleA12H.pm

#!/usr/bin/perl
use strict;
use Exporter qw(import);
our @EXPORT_OK = qw(test);

package MyModuleA12H;

sub test {
    return 'content...';
}

1;

and here my ./index.pl

#!/usr/bin/perl
print 'Content-type: text/html\r\n\r\n';

print '<html><head><title>HI</title></head><body>';
use File::Basename qw(dirname);
use Cwd qw(abs_path);
use lib dirname($0) . '/libs';
require MyModuleA12H;

print '<div>';
print MyModuleA12H::test();
print '</div>';

print '</body></html>';

locally it works but if I commit and reload I get a file not found.

EDIT

Looks like a permission issue or something. If I comment all the "use" part index.pl cannot be found.

EDIT 2

I made a little mess with the single quotes in

print 'Content-type: text/html\r\n\r\n';

that should be ", now it works, thanks to Borodin for the suggestions I'm applying those changes.

1 Answer 1

1

You need use MyModuleA12H instead of require MyModuleA12H, as require won't call the module's import method

And your package statement is too late, so you are importing Exporter::import into main instead of MyModuleA12H

This is how it should look

#!/usr/bin/perl

use strict;
use warnings;

package MyModuleA12H;

use Exporter qw( import );

our @EXPORT_OK = qw( test );

sub test {
    'content...';
}

1;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.