Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: @INC order not followed

by ikegami (Patriarch)
on Oct 19, 2022 at 19:17 UTC ( [id://11147522]=note: print w/replies, xml ) Need Help??


in reply to @INC order not followed

The correct modules are being loaded. f CSV was simply too vague, matching multiple files.


Let's start by looking at what f does.

f filename

Switch to viewing a different file or eval statement. If filename is not a full pathname found in the values of %INC, it is considered a regex.

evaled strings (when accessible) are considered to be filenames: f (eval 7) and f eval 7\b access the body of the 7th evaled string (in the order of execution). The bodies of the currently executed eval and of evaled strings that define subroutines are saved and thus accessible.

You did not provide a full path, so you provided a regex.

As it turns out, there were more than one match for the regex pattern CSV. /var/www/cgi-bin/project/CSV.pm matched. Your program also loads Text::CSV, so /usr/local/share/perl5/Text/CSV.pm matched as well. But there are at least two more matches.

Text::CSV is not a CSV parser. It's a front end for Text::CSV_PP and Text::CSV_XS. It loads one of these modules, and it does so using an eval. This is the match you obtained. The eval that was used to load Text:CSV_XS (which is also a match).

So that's four possible matches for your query, and I suspect you get one "at random".


To get the correct file, first find out which one was loaded by a use/require.

If you used the bareword syntax (use Foo or require Foo rather than require "Foo.pm"), first convert the bareword to a string using these rules: Replace every :: with / (even on Windows), then append .pm.

Then look at the the value of the element of %INC that has that string for key.

DB<1> x $INC{"CSV.pm"} 0 '/var/www/cgi-bin/project/CSV.pm' DB<2> x $INC{"Text/CSV.pm"} 0 '/home/ikegami/usr/perlbrew/perls/5.36.0t/lib/site_perl/5.36.0/Text +/CSV.pm' DB<3> x $INC{"Text/CSV_XS.pm"} 0 '/home/ikegami/usr/perlbrew/perls/5.36.0t/lib/site_perl/5.36.0/x86_ +64-linux-thread-multi/Text/CSV_XS.pm'

Alternatively, you could perform the same search f CSV performs.

DB<4> x grep /^_<.*CSV/, keys %:: 0 '_<(eval 11)[/home/ikegami/usr/perlbrew/perls/5.36.0t/lib/site_perl +/5.36.0/Text/CSV.pm:136]' 1 '_</home/ikegami/usr/perlbrew/perls/5.36.0t/lib/site_perl/5.36.0/x8 +6_64-linux-thread-multi/Text/CSV_XS.pm' 2 '_</home/ikegami/usr/perlbrew/perls/5.36.0t/lib/site_perl/5.36.0/Te +xt/CSV.pm' 3 '_</var/www/cgi-bin/project/CSV.pm'

From there, you can use f

f /var/www/cgi-bin/project/CSV.pm

Finally, if your module was named My::CSV and stored as /var/www/cgi-bin/project/My/CSV.pm, you could have used

f My/CSV
since that only has one match.

Replies are listed 'Best First'.
Re^2: @INC order not followed
by misterperl (Pilgrim) on Oct 20, 2022 at 16:26 UTC
    TY All for the enlightening info, Im a better JAPH for it!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11147522]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-25 19:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found