Based on what you've posed here, you definitely don't need to use the eval with require BAREWORD;, require "/path/to/filename.pm"; would be much easier in your case. Also, note that despite its several caveats, a glob might be easier than opendir in this case. Here's an example, where $stylespath is an absolute pathname (see do for the rules on when @INC will be searched and when it won't):

use File::Glob 'bsd_glob'; my $style = $ARGV[1]; die "bad style" unless $style=~/\A\w+\z/; require $_ for bsd_glob("$stylespath/$style/*.pm");
the subroutines are still undefined: Undefined subroutine &modes::three::flex I'm not sure why this is.

What package statement (if any) does english/eight.pm start with? If it's e.g. package eight;, then a sub flex in that file declares a subroutine whose full name is &eight::flex.

Note that the AM post does not name one caveat of UNIVERSAL's can method, which is that it also searches the package's ancestry via @ISA for that method - if you don't set @ISA in your packages, it's fine, but if you do, then you need to be aware of this. If you want to avoid that, then this is IMO one of those rare cases where symbolic refs can help: my $package = 'eight'; my $subref = do { no strict 'refs'; \&{$package.'::flex'} };.

Update: That you've traced it down to this issue also helps explain what you described in your root node, that you see a difference between 5.18 and 5.26: Removal of the current directory (".") from @INC may explain your issue. But my suggestions above still stand!


In reply to Re^5: Parsing Problems (updated) by haukex
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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.