Hello Monks,

I'm having an issue with one of my scripts where I try and require other Perl modules via eval 'require' using the -I flag and it fails, whereas it works via another eval 'require' in another script, where the includes directories are more hardcoded into the script.

Code:

Module Validator (simple):
#====================== #BEGIN MODULE VALIDATOR #====================== #!/usr/intel/bin/perl -dw use vars qw( $TOP_MODULE $DEBUG ); use pm::Common; use package_name::module; $DEBUG=0; $TOP_MODULE="Module Validator"; &error(-1, "Inappropriate arguments specified! One, and only one, modu +le must be defined") if($#ARGV != 0); &error(-2, "Bad module syntax. Only a-z, A-Z, 0-9, '_' are allowed fo +r the name, with :: as package scoping separators") if($ARGV[0] =~ /[ +^\w:\.]/); local $@=0; eval 'require "'.$ARGV[0].'";'; if($@) { &error(1, "Failed include stage for '$ARGV[0]'. Error message:\n$@ +"); } else { # ... } print "$ARGV[0]: Valid\n"; sub error { &Common::error(@_); } #====================== #END MODULE VALIDATOR #======================
try/foo.pm:
#===================== #BEGIN FOO::TRY #===================== package foo::try; + + use pm::Common; + + + 1; #===================== #END FOO::TRY #=====================
Run / output:
filc8166[559]% perl -I`pwd` ./bin/Module_Validator.pl foo::try + + Loading DB routines from perl5db.pl version 1.27 Editor support available. + + Enter h or `h h' for help, or `man perldebug' for more help. + + DB<1> s main::((eval 7)[./bin/Module_Validator.pl:16]:1): 1: require "foo::try"; main::(./bin/Module_Validator.pl:7): 7: DB<2> c (Module Validator) ERROR: Failed include stage for 'foo::try'. Error m +essage: Can't locate foo::try in @INC (@INC contains: /nfs/fm/disks/fm_vt_n190 +29/users/gwcooper/vibe_regress /usr/intel/pkgs/perl/5.8.5/lib/5.8.5/i +686-linux-64int /usr/intel/pkgs/perl/5.8.5/lib/5.8.5 /usr/intel/pkgs/ +perl/5.8.5/lib/site_perl/5.8.5/i686-linux-64int /usr/intel/pkgs/perl/ +5.8.5/lib/site_perl/5.8.5 /usr/intel/pkgs/perl/5.8.5/lib/site_perl .) + at (eval 7)[./bin/Module_Validator.pl:16] line 1. + + Backtrace: at ./bin/Module_Validator.pl line 40 main::error(1, 'Failed include stage for \'foo::try\'. Error m +essage:\x{a}Can\'t ...') called at ./bin/Module_Validator.pl line 19 Debugged program terminated. Use q to quit or R to restart, use O inhibit_exit to avoid stopping after program termination, h q, h R or h O to get additional info. DB<2> q filc8166[560]% pwd /nfs/fm/disks/fm_vt_n19029/users/gwcooper/vibe_regress filc8166[561]% ls foo/ try.pm

Any ideas what could be wrong?

Thanks in advance!

-Garrett


In reply to Issues with including via eval 'require' by yaneurabeya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.