Malcolm Nooning wrote:
> Is this expected behavior?
I never asked myself that question. Before I make an attempt at an
answer, I have to note that "use mylib::t2b;" implies that the line
"package mylib::t2b;" is in the lower level package. I will assume
you did and drop this part.
As far as expected behavior is concerned, you got me to wondering
about it, so I looked up
http://www.oreilly.com/catalog/prkunix/excerpt/PWPMch01.html#MARKER-9-47
because they have a "use versus require" section in it.
If I read it correctly, one cannot just state (within t1.pl)
"DoIt();" You would have to state "mylib::DoIt();". On the other
hand, the document is assuming modules, not .pl files. In fact, I did
not know code could "require" a .pl file at all. I thought you could
only require a module. Since your code works, well, I now know
otherwise, but I don't know where there is documentation on requiring
a .pl file.
Do you know where there is documentation on using "require something.pl;"?
In the 2nd edition of the camel book, which I had handy, it explains
requiring a file like this first, then using a package name. Require
"file" is similar to an include statement in other languages, but a bit
smarter than do(). I'll bet it's been in there since before modules and
OO capabilities were added to the language.
I just checked the perlfunc with the ActivePerl 5.8.8 I'm using and this
usage is not very obvious. It would be the case where EXPR is NOT a
bareword. Since require uses do() to read in the filename specified by
EXPR, the implication is that filename would need to contain Perl
statements, but it doesn't have to have a .pl suffix.
Garyl