in reply to Re^2: Can't locate IO/Scalar.pm in @INC (@INC contains: /opt/rocks/lib/perl5/5.8.8/
in thread Can't locate IO/Scalar.pm in @INC (@INC contains: /opt/rocks/lib/perl5/5.8.8/

The last line 'open(...) = 4' shows that IO/Scalar.pm is successfully opened (so, I suppose you don't get the "Can't locate..." error in this case when just plain loading nothing but the module).

What do you get when you replace "perl -MIO::Scalar -e1" in the strace command with a call to your actual script that exhibits the problem? (Depending on how exactly you're calling the script (e.g. via shell wrapper), you might need the additional option -f to strace. In case of doubt, specify it anyway.)  Maybe the script itself is messing with @INC, or some such...  BTW, are you sure that you're using the same perl (i.e. /usr/bin/perl) to run the script?

Replies are listed 'Best First'.
Re^4: Can't locate IO/Scalar.pm in @INC (@INC contains: /opt/rocks/lib/perl5/5.8.8/
by donghe (Initiate) on Apr 24, 2009 at 02:52 UTC
    I also found that directories in @INC mentioned in error message and that gotten by using "perl -V" are some different.

    from error message:
    Can't locate IO/Scalar.pm in @INC (@INC contains:
    /home/donghe/iprscan/lib
    /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8
    /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_per /5.8.6
    /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.8 /
    usr/lib/perl5/vendor_perl/5.8.7
    /usr/lib/perl5/vendor_perl/5.8.6
    /usr/lib/perl5/vendor_perl/5.8.5
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8
    .)

    from perl -V
    @INC: /usr/lib/perl5/site_perl/5.8.8//i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.8/
    /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.8
    /usr/lib/perl5/site_perl/5.8.7
    /usr/lib/perl5/site_perl/5.8.6
    /usr/lib/perl5/site_perl/5.8.5
    /usr/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.8
    /usr/lib/perl5/vendor_perl/5.8.7
    /usr/lib/perl5/vendor_perl/5.8.6
    /usr/lib/perl5/vendor_perl/5.8.5
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/5.8.8/i386-linux-thread-multi
    /usr/lib/perl5/5.8.8

    if I put Scalar.pm in '/home/donghe/iprscan/lib', this problem is solved! however '/home/donghe/iprscan/lib' is not included in the @INC showed by using 'perl -V'. do you know the reason?

      perl -V lists the hardcoded initial value for @INC. The error message includes @INC as it was when the require was executed. @INC can be modified directly, or by using env var PERL5LIB, env var PERLLIB, module lib or the command line option -I (via command line, shebang or env var PERLOPTS).
      Did you show the entire output of 'perl -V' ?
      Usually the current working directory ('.') is in @INC, and if '/home/donghe/iprscan/lib' is your current working directory, then '/home/donghe/iprscan/lib/IO/Scalar.pm' would be found by use IO::Scalar;. (Note that the @INC, as reported by the error message *does* include '.')

      However, it can never make any sense that '/home/donghe/iprscan/lib/Scalar.pm' would be found by attempting to use IO::Scalar;

      And whatever happened to the perl that's in /opt (referenced in your original post) ?

      Cheers,
      Rob