Professional Web Applications Themes

How to change INC - PERL Beginners

Hi all, I'm tring to load a module with: use Fcntl; but I get an error like: Can't locate Fcntl.pm in INC (INC contains: /opt/perl5/lib/5.00502/PA-RISC1.1 /opt/perl5/lib/5.00502 /opt/perl5/lib/site_perl/5.005/PA-RISC1.1 /opt/perl5/lib/site_perl/5.005 ..) at ./sp_file line 3. BEGIN failed--compilation aborted at ./sp_file line 3. how can I fix this error telling perl to search in corretc path (that is /opt/perl/lib/5.6.1/PA-RISC1.1-thread-multi/Fcntl.pm)? Thank You...

  1. #1

    Default How to change INC

    Hi all, I'm tring to load a module with:

    use Fcntl;

    but I get an error like:

    Can't locate Fcntl.pm in INC (INC contains: /opt/perl5/lib/5.00502/PA-RISC1.1 /opt/perl5/lib/5.00502 /opt/perl5/lib/site_perl/5.005/PA-RISC1.1 /opt/perl5/lib/site_perl/5.005 ..) at ./sp_file line 3.
    BEGIN failed--compilation aborted at ./sp_file line 3.

    how can I fix this error telling perl to search in corretc path (that is /opt/perl/lib/5.6.1/PA-RISC1.1-thread-multi/Fcntl.pm)?

    Thank You

    Mauro Guest

  2. #2

    Default Re: How to change INC

    you can solve in your script:

    #!/usr/bin/perl
    use lib '/opt/perl/lib/5.6.1/PA-RISC1.1-thread-multi';
    use Fcntl;
    ..........................................

    or setting the environmental variable PERL5LIB.

    Remo


    On Apr 28, 2004, at 2:19 PM, Mauro wrote:
     

    Remo Guest

  3. #3

    Default Re: How to change INC

    Please bottom post...
     

    Uh, better be very very careful with this. The Perl versions are
    different which is why it isn't finding the module in the normal 5.6.1
    version directories, and I suspect in this case they are not binary
    compatible, which could be important to Fcntl. One also seems to be
    thread enabled and the other not.

    OP, I would suggest installing the Fcntl module (which I thought would
    have come with it) using the 5.00502 version of Perl or switching to the
    5.6.1 for your script. If you choose not to do this you better test the
    hell out of the script.

    http://danconia.org

     [/ref]

    Wiggins Guest

  4. #4

    Default Re: How to change INC





    This might work, I have not tried it, but it might.

    unshift (INC, "/opt/perl/lib/5.6.1/PA-RISC1.1-thread-multi");
    use Fcntl;


    __________________

    William Ampeh (x3939)
    Federal Reserve Board



    "Mauro"
    <mauoginterfree To: <org>
    .it> cc:
    Subject: How to change INC
    04/28/2004 08:19
    AM
    Please respond
    to "Mauro"






    Hi all, I'm tring to load a module with:

    use Fcntl;

    but I get an error like:

    Can't locate Fcntl.pm in INC (INC contains:
    /opt/perl5/lib/5.00502/PA-RISC1.1 /opt/perl5/lib/5.00502
    /opt/perl5/lib/site_perl/5.005/PA-RISC1.1 /opt/perl5/lib/site_perl/5.005 .)
    at ./sp_file line 3.
    BEGIN failed--compilation aborted at ./sp_file line 3.

    how can I fix this error telling perl to search in corretc path (that is
    /opt/perl/lib/5.6.1/PA-RISC1.1-thread-multi/Fcntl.pm)?

    Thank You



    William Guest

  5. #5

    Default Re: How to change INC

    On Apr 28, gov said:
     

    It is usually pointless to modify INC with push() or unshift(). You
    should always use

    use lib "directory";

    --
    Jeff "japhy" Pinyan com http://www.pobox.com/~japhy/
    RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
    CPAN ID: PINYAN [Need a programmer? If you like my work, let me know.]
    <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.

    Jeff Guest

  6. #6

    Default Re: How to change INC

    Hi!
     [/ref]

    You can push || unshift(INC, 'some directory').

    Best regards,
    Jan
    --
    cat /dev/world | perl -e "while (<>) {(/(^.*?\?) 42\!/) && (print $1)}"
    errors->(c)
    -
    Jan Guest

  7. #7

    Default Re: How to change INC


     [/ref]
    >
    > You can push || unshift(INC, 'some directory').
    >[/ref]

    As Jeff mentioned this is not sufficient. The reason is because modules
    are loaded at compile time when 'use'd which means the update to INC
    must happen at compile time, the above happens at runtime unless you add
    a BEGIN block around it.

    Better to use 'lib' pragma.

    perldoc lib

    But again, including a directory from a different version of Perl sounds
    like headaches to me.

    http://danconia.org
    Wiggins Guest

  8. #8

    Default Re: How to change INC

    They are all correct in saying either
    unshift INC, "your path"; or push INC, "your path";
    but better achieve this in
    BEGIN{} module, so that you are assured that INC is changed before the
    use <>; statement is evaluated.

    Sumanth Sharma




    Sumanth Guest

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139