in reply to Dynamically load unknown modules

First off, personally I stay as far away from indirect object syntax as I can. It _will_ bite you at some point or another. Replace that new $name to $name->new() and teach yourself never to use the syntax and youll never get bitten.

As for the solution to your problem it seems like it would be pretty likely that its due to filename case issues on your system. The file name is probably: api/bess/query/Query.pm but the package name is "Api::Bess::Query" so when you require it you cant directly use the filespec to determine the actual package contained. This is more serious than you may think as the rules do NOT say that the contents of a file that is use()d/require()d is the same as the file is named. Thus there is no reliable way to go from the filename to the package name that it contains. For instance

#file: Bar.pm packge Foo; sub yada { print "...\n" }; __END__ perl -MBar -e "Foo::yada()"
should work just fine.

Thus you will need to parse the file looking for package statements. This gets even more complex in that a file can contain multiple packages (I do this very often indeed) and also could be dynamically creating packages at run or compile time. Thus the file when required may actually generate a class and not contain anything parseable.

So parse the file for package statements and then act apon them, but expect that it wont be a generalized solution.

UPDATE: I suppose what you could do is find out the packages that exist prior to the require as well as after, filter the ones that already existed and then go from there. I know its possible but offhand im not sure how to do it. Id have to research into it more extensively than I have time. Perhaps a guru (there are more :-) is around that can clarify the approach.

Yves / DeMerphq
---
Software Engineering is Programming when you can't. -- E. W. Dijkstra (RIP)