in reply to Moose in a module created with h2xs

Do I need to specify "use Moose" in every package I define in that .pm file?

I'd say so. use Moose; will, among other things, import functions like has into the current package, and although I'm sure there are ways to be tricky about it, IMO the best thing really is to put a use Moose; in every package using it.

All those "our" declarations and the "require", generated by h2xs

It depends, OO modules usually don't export stuff as well, so personally I would remove the require Exporter; and the our declarations, except for our $VERSION.

Also, note that it's usually considered good practice to only have one package per file. Since Moose also turns on strict and warnings, the bare minimum you need in a .pm file using it is:

package Foo::Bar; use Moose; # your code here 1;

(The use 5.022; might be helpful because it turns on the 5.22 feature bundle, if you're sure you want to limit the minimum Perl version to that.)

Replies are listed 'Best First'.
Re^2: Moose in a module created with h2xs
by rpaskudniak (Novice) on Feb 22, 2019 at 20:07 UTC
    Thanks, haukex.

    Since I will definitely be exporting a select set of functions I will require (ahem) that Exporter business. I will take your advice about the re-use of Moose in each package; some documentation (buried in Moose::Manual I think) seems to indicate that. The same docs kept giving examples with multiple packages in one source file. On the other hand, the constructs generated by h2xs seem safe to pull out in front of all packages. I'll have to write a test module and see how that plays out. I'll let y'all know what happened.

    Again, thanks.