in reply to Package problems

Anonymous Monk 2 above is right in the general sense that you probably want to familiarize yourself with a Perl object framework like Moose, but that is not the answer to your question. Likewise, strict would help but does not answer your question (see Use strict warnings and diagnostics or die).

When you call Dog::play ($name); you are not passing the idea of a variable called $name to Dog::play, but the contents the the variable in current scope. You call Dog::play ($name); in the Cat package, and it has variable called $name. So Perl inserts Garfield into the argument list.

Of course, this is further confused by your use of our and lack of scope declaration for $name = "Garfield";. If instead you write our $name = "Garfield";, you can now get the two different results by calling

Dog::play ($Dog::name); # Prints Odie catches a tennis ball.
Dog::play ($name); # Prints Garfield catches a tennis ball.

The comments about better methodology would have helped catch and clarify these issues a number of different ways.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.