note
haukex
<p>Based on what you've posed here, you definitely don't need to use the <c>eval</c> with <c>require BAREWORD;</c>, [doc://require|<c>require "/path/to/filename.pm";</c>] would be much easier in your case. Also, note that despite its [id://1206848|several caveats], a [doc://glob] might be easier than [doc://opendir] in this case. Here's an example, where <c>$stylespath</c> is an absolute pathname (see [doc://do] for the rules on when <c>@INC</c> will be searched and when it won't):</p>
<c>
use File::Glob 'bsd_glob';
my $style = $ARGV[1];
die "bad style" unless $style=~/\A\w+\z/;
require $_ for bsd_glob("$stylespath/$style/*.pm");
</c>
<blockquote><i>the subroutines are still undefined: <c>Undefined subroutine &modes::three::flex</c> I'm not sure why this is.</i></blockquote>
<p>What <c>package</c> statement (if any) does <c>english/eight.pm</c> start with? If it's e.g. <c>package eight;</c>, then a <c>sub flex</c> in that file declares a subroutine whose full name is <c>&eight::flex</c>.</p>
<p>Note that the AM post does not name one caveat of [doc://UNIVERSAL]'s <c>can</c> method, which is that it also searches the package's ancestry via [doc://@ISA] for that method - if you don't set <c>@ISA</c> 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: <c>my $package = 'eight'; my $subref = do { no strict 'refs'; \&{$package.'::flex'} };</c>.</p>
<p><b>Update:</b> 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: [doc://perl5260delta#Removal-of-the-current-directory-(".")-from-@INC] may explain your issue. But my suggestions above still stand!</p>
1233707
11100033