Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

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

Thank you for your reply. This is helpful as I've traced the error to how Perl is handling the modules, @INC, and referencing subroutines.

What my code is supposed to do is apply different sets of transformations to a text file based on options specified from the command-line:

 modes.pl [rawtext] [style] [mode](one, two, etc.) [1st variation](a, a_prime, b, etc.) [2nd variation]

"style" is one of several directories containing nine .pm files. Each .pm file has at least the subroutines "first" and "flex." The other subroutines are variations.

Here is the code that I'm using to load the modules:

package modes; my $lP; my $modCount = 0; BEGIN{ $lP = "$ARGV[1]"; } use lib $lP; if(opendir(LIB, $lP)){ foreach my $l (readdir(LIB)){ unless ($l !~ /^(.*)\.pm$/){ eval qq~require ~ . $ARGV[1] . qq~::~ . $1 . qq~;~; print $@; } } }

The error that code produces (given: ./modes.pl "filename" english three a b) in Perl 5.26.1 (error does not occur in 5.18.2) is the following:

Can't locate english/eight.pm in @INC (you may need to install the eng +lish::eight module) (@INC contains: english /home/******/perl5/lib/pe +rl5/5.26.1/x86_64-linux-gnu-thread-multi /home/*********/perl5/lib/pe +rl5/5.26.1 /home/***/perl5/lib/perl5/x86_64-linux-gnu-thread-multi /h +ome/******/perl5/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/ +perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/pe +rl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/sh +are/perl/5.26 /home/****/perl5/lib/perl5/5.26.0 /home/*****/perl5/lib +/perl5/5.26.0/x86_64-linux-gnu-thread-multi /usr/local/lib/site_perl +/usr/lib/x86_64-linux-gnu/perl-base) at (eval 5) line 1.

Setting $lP to the fully qualified PWD (or simply "." since the "english" directory is located here) fixes that error, but the subroutines are still undefined:

Undefined subroutine &modes::three::flex

I'm not sure why this is. I will change my code based on your recommendations, but I don't understand it well enough myself to do so yet. I borrowed the module loading code from another programmer years ago simply because it did what I needed - I never fully understood it.


In reply to Re^4: Parsing Problems by ftherese
in thread Parsing Problems by ftherese

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 chanting in the Monastery: (7)
As of 2024-04-23 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found