Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.

In reply to Re: @INC order not followed by ikegami
in thread @INC order not followed by misterperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-24 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found