in reply to Re: Require - Module inclusion
in thread Require - Module inclusion

Hi,
Thanks for mail.
I have tried your suggestion.
it's not working for me.
I found that  raja is hardcoded . Can you please try like this ?
my $pack='raja.pm'; unshift(@INC,"XX/XDC"); require "$pack"; $obj = $pack->new(); print $obj;

Let me know your comments.
-kulls

Replies are listed 'Best First'.
Re^3: Require - Module inclusion
by agianni (Hermit) on Mar 16, 2007 at 14:48 UTC

    A couple of comments:

    • I would avoid using a relative path in your @INC. That seems rather fragile. Actually, avoid using relative paths in general.
    • Insted of unshifting onto @INC, use lib, it does exactly that.
    • Generally, we name our module files with a .pm extension, but our package/class names don't include the .pm, so you'll need to address that when you call new on the package name

    Given those suggestions, try this:

    # assume this is hard coded my $package = 'raja.pm'; use lib qw ( /full/path/to/XX/DC ); # get the package name without the .pm my ( $class ) = split /\./, $package; # require by package name require $package; # call new on the class (raja) my $obj = $class->new(); print $obj;
    perl -e 'split//,q{john hurl, pest caretaker};print join q{},map{@_[$_]}q{00061314041703012005120710111907081505211622192409}=~/\d{2}/g;'