Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^5: Parsing Problems (updated)

by haukex (Archbishop)
on May 15, 2019 at 22:01 UTC ( [id://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/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!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-18 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found