in reply to scope and declaration in local packages

You're calling Animal::Hog->sound() too early for the variables to have been assigned a value.  Put the call after the block wherein you define the package, and things will work. Or use a BEGIN block.

The initialisation of the variables happens at runtime (execution of the block), while the setting up of the subroutines happens at compile-time.

(Also, in a real program, you'd probably want to call the constructor (new) to create an object instance — otherwise you might as well use regular non-OO subroutines (as opposed to methods)...)