kmullin has asked for the wisdom of the Perl Monks concerning the following question:

We're on Perl 5.8.8. We have an internally developed Perl Module, that is brought into a program with the use statement. When we attempt to use the program with an environment variable set to a specific value, I get an 'out of memory' condition. I've trace code insode the Perl Module to this statement:

if ($ENV{AMAZON_ENVIRONMENT} =~ /jp-/ && ! $ENV{DISABLE_SJISTERMFILTER +} ) { require Amazon::DistributionCenter::SJISTermFilter;

SJISTermFilter is also developed internally. One of the thing I see there is:

my $IN_FILTER = q/sub{Jcode::convert($_[0], 'utf8', 'sjis');}/;

I've googled this 'Jcode' module, and see that the latest/greatest version is 2.06. I've search our libraries and have found our Jcode module is at 2.03. Do you suppose this could be my problem?

Replies are listed 'Best First'.
Re: PM module processing problem
by former33t (Scribe) on Dec 07, 2007 at 19:38 UTC
    If you know that this internally developed module has worked in the past, I'd be less concerned about your version of Jcode (unless you just recently upgraded it).

    I'd suggest you do two things:

    1. Inspect what is being passed into the statement above. Since it looks like you are taking the zero index element of the default array, how big is the array?

    2. Develop a quick test script that also require's the Amazon::DistributionCenter::SJISTermFilter module. If it works, there is something else causing the memory problem besides just requiring the module.

    FWIW, I've never worked with Jcode before, so I'm just passing on some general ideas.

      Thank you for your 'general ideas', that's all I'm looking for. The module is very large, so I've already got a minimal example. It is:

      #!/apollo/bin/env perl + # This is one of the most unbelievably hackish things I've ever done, # but it seems to be the only way to get this script to run in perl-5. +8 # while still allowing other scripts on this server to run in perl-5.6 # -davkent BEGIN { print "Removing perl.5.6.0 libraries\n"; my $cntr = 0; foreach $path(@INC) { if($path =~ /(.*)(perl.5.6.0)(.*)/) { print "Removing $path\n"; $INC[$cntr] = '.'; } $cntr++; } unshift @INC, "/home/kmullin/Jcode-2.06"; print "Done removing perl libraries\n"; print "Path is now:\n"; foreach $path(@INC) { print $path . "\n"; } } use Amazon::DistributionCenter::Setup; print "hello world.\n";

      The shebang is something we need to do around here to set up the environment, the BEGIN block is to eliminate perl 5.6 libraires, so that we can use 5.8. If you remove the entire begin block, it still gets 'Out of Memory'. It never makes it to print 'Hello, world'. By the way, I just added the unshift command in here as a way to get JCode version 2.06 into the picture. I thought that the problem may be caused by our JCode being 2.03, needing 2.06. I downloaded 2.06, put it into /home/kmullin/Jcode-2.06 thinking that perl would find it there, but its not working, it still hangs, making me think the problem is somewhere else.