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

Re^5: Parsing Problems (updated)

by haukex (Bishop)
on May 15, 2019 at 22:01 UTC ( #11100044=note: print w/replies, xml ) Need Help??

in reply to Re^4: Parsing Problems
in thread Parsing Problems

Based on what you've posed here, you definitely don't need to use the eval with require BAREWORD;, require "/path/to/"; 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/ 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!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2022-05-29 09:05 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (101 votes). Check out past polls.