Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Can't find function in @INC

by bangor (Beadle)
on May 04, 2014 at 18:09 UTC ( #1084955=perlquestion: print w/ replies, xml ) Need Help??
bangor has asked for the wisdom of the Perl Monks concerning the following question:

I was asked this in a test but have never seen it anywhere before:
What does "Can't find function in @INC" mean?
I have only seen this with regard to modules, and Google didn't turn up anything. Any ideas?

Comment on Can't find function in @INC
Re: Can't find function in @INC
by amon (Beadle) on May 04, 2014 at 18:28 UTC

    You are absolutely correct. The error “Can't locate Module.pm in @INC” exists, but AFAIK no such error message referring to functions does. So there are two and a half possibilities:

    • It is a trick question to test your knowledge of Perl. Explain how a similar error regarding modules does exist, and what the role of @INC is.
    • The question contains a mistake. This is the most likely explanation, considering that perldiag has no entry for such an error message.
    • There is some surprising new behavior in Perl which neither you nor I am not aware of. While possible, this isn't exactly the most likely explanation.
      > This is the most likely explanation, considering that perldiag has no entry for such an error message.

      hmm did you notice that Can't locate Module.pm in @INC is not in perldiag?

      The corresponding error is only called Can't locate %s

      Which means searching for '@INC' wouldn't help...

      Though you're right about the full message:

      perl -Mdiagnostics -Mdummy Can't locate dummy.pm in @INC (@INC contains: /etc/perl /usr/local/lib +/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/p +erl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl + .). BEGIN failed--compilation aborted (#1) (F) You said to do (or require, or use) a file that couldn't be found. Perl looks for the file in all the locations mentioned in @ +INC, unless the file name included the full path to the file. Perhaps +you need to set the PERL5LIB or PERL5OPT environment variable to say w +here the extra library is, or maybe the script needs to add the library + name to @INC. Or maybe you just misspelled the name of the file. See perlfunc/require and lib.

      Cheers Rolf

      ( addicted to the Perl Programming Language)

        LanX meet splain
        Can't locate Module.pm in @INC Can't locate Module.pm in @INC (#1) (F) You said to do (or require, or use) a file that couldn't be fo +und. Perl looks for the file in all the locations mentioned in @INC, un +less the file name included the full path to the file. Perhaps you nee +d to set the PERL5LIB or PERL5OPT environment variable to say where +the extra library is, or maybe the script needs to add the library nam +e to @INC. Or maybe you just misspelled the name of the file. See "require" in perlfunc and lib.
Re: Can't find function in @INC
by Anonymous Monk on May 04, 2014 at 18:34 UTC

    I was asked this in a test but have never seen it anywhere before:

    Neither has the test asker :)

Re: Can't find function in @INC
by Laurent_R (Parson) on May 04, 2014 at 18:56 UTC
    If people asking interview tests were asking stupid questions, people would know about it, no?

    Oooh, did I goof? Sorry.

      This was a written test, not an interview - I should have pointed that out.
        Still, I have seen a number of times written questions that were ambiguous enough to deserve two conflicting or even opposite answers, depending on the level at which you wanted to answer. When you are supposed to give a written answer, you can explain that there are different levels of answers (and hope that the corrector will understand what you mean, I have at least once been in a formal university exam situation where the corrector had no understanding of what I explained to be ambiguous, and I was able to check with the top professor that I was right making a two-sided answer and that the corrector simply did not understand the deepest thoughts that I was expressing, but that's rather uncommon).

        And then, there is the multiple-choice type of tests, where you usually have no chance to explain your choice and are at a great difficulty to figure out whether the authority (college or university professor, job interviewer, whatever) is asking for the simple immediate answer, or for a more clever response. I really hate this type of situation. Ambiguity should really be banned from such tests.

Re: Can't find function in @INC (Can’t locate auto/%s.al in @INC)
by LanX (Canon) on May 04, 2014 at 19:44 UTC
    You can always search perldiag for unknown error messages (that's what diagnostics does)

    The closest I was able to find (searching for '@INC') was

    Can’t locate auto/%s.al in @INC

    but I have problems to decrypt the description.

    (F) A function (or method) was called in a package which al +lows autoload, but there is no function to autoload. Most proba +ble causes are a misprint in a function/method name or a failur +e to "AutoSplit" the file, say, by doing "make install".

    I'm ignorant about how to "allow autoload" w/o actually having provided a sub AUTOLOAD somewhere.

    Probably either a weird case of inheritance mess up or some kind of XS magic (?).

    edit

    ah, google is my friend! )

    --> What is the /auto/ directory used for? see also AutoSplit

    lazy me! (I blame LanX! ;-)

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Re: Can't find function in @INC
by tobyink (Abbot) on May 04, 2014 at 20:27 UTC

    This is pretty close...

    $ perl -e'require q/function/' Can't locate function in @INC (@INC contains: ...) at -e line 1.
    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
      Ah, so the answer should be "the script tried to require a module called 'function' ...". It is a deliberately confusing question, though I suppose it does sort the wheat (you tobyink) from the chaff (me bangor).
Re: Can't find function in @INC
by sundialsvc4 (Monsignor) on May 05, 2014 at 14:58 UTC

    It is a pretty-good test question, though, because if you have dealt with the Perl environment for any length of time at all, you will have encountered it and you will therefore understand what it means.   Eventually you will tpyo a module-name in a use declaration . . .

      Except that if you do that you won't be told "Can't find function in @INC", you'll be told something like ...

      $ perl -E 'use Gargh' Can't locate Gargh.pm in @INC (@INC contains: ...)

      The question is wrong. If it were a closed-book test I'd write something like that I've never seen it before but would guess at it being some kind of mal-formed subroutine reference that got pushed into @INC.

      After RingTFM the closest I can get is this, although I don't recall ever seeing this construction in real life:

      $ perl -E 'push @INC, bless({}, "Foo");require Gargh' Can't locate object method "INC" via package "Foo" at -e line 1.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1084955]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-09-16 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (9 votes), past polls