in reply to perl unable to locate my module

Here's where things stand, taking into account various people's suggestions:

I moved the module to /internal/charrison/. Every directory from root on down is 0777. Still same problems.

require '/internal/charrison/IPC.pm'; works! (However, it fails when IPC.pm issues 'use WDI;')

When clhtest (normally invoked by xinetd) is invoked from command line, it works fine, fork/exec'ing 'test'.

I think I am having some issues with the Perl 'exec' statement (whose documentation I frankly can't fathom). When I write

$command = q{/usr/bin/perl}; @arglist = q{-I /internal/charrison /internal/charrison/test -l /inter +nal/charrison -P /internal/charrison}; exec $command @arglist;
It fails in the usual manner. But when I write
exec "$command @arglist";
it *does* load IPC.pm successfully -- but then it chokes when IPC.pm does 'use WDI.pm;', like above. At this point I wonder if there's something wrong with the command string I'm passing to exec. (I now realize there are several different ways of giving paramenters to exec(), but I don't understand them, so I should probably stick to the single-argument model.)

Replies are listed 'Best First'.
Re^2: perl unable to locate my module
by Anonymous Monk on May 23, 2013 at 07:04 UTC
    Um, try
    @perl = qw{ /usr/bin/perl -I /internal/charrison }; @program = qw{ /internal/charrison/test }; @args = qw{ -l /internal/charrison -P /internal/charrison }; @cmd = ( @perl, @program, @args ); use Data::Dump; dd( \@cmd ); exec @cmd;
    cause
    [ "/usr/bin/perl", "-I", "/internal/charrison", "/internal/charrison/test", "-l", "/internal/charrison", "-P", "/internal/charrison", ]

    This avoids the shell.

      That seems to have solved the problem. I don't understand how avoiding the shell made any difference, since from what I can make of the exec() doc, involving the shell mainly allows metacharacters to be interpreted.

      However, based on your solution, it appears that the safest way to pass multiple arguments to exec() is in an array of "words" (as defined by qw//).

      Thank you for your help!