Use a good library to read input.† The Getopt::Long is excellent and practically a standard
use warnings;
use strict;
use feature 'say';
use Getopt::Long;
use List::Util qw(any);
my ($country, $husband, $wife, $child, $pet);
GetOptions(
'country=s' => \$country,
'husband=s' => \$husband,
'wife=s' => \$wife,
'child|kid=s' => \$child,
'pet=s' => \$pet
);
# If they all must be submitted, and no other input, check
usage() if any { not defined $_ } $country, $husband, $wife, $child, $pet;
usage() if @ARGV;
say "Family of $wife and $husband come from $country";
sub usage {
say STDERR "
Usage: $0 ...
All listed arguments are mandatory.
No other input is supported.
";
exit;
}
An option value with multiple words is supplied under quotes. I show above how to set up alternate names for input options, they can be shortened as long as unambiguous, one hyphen can be dropped, etc.
program.pl --husband Ken -w "Jo Ann" -kid May
Please see documentation for far more features in library's use.
Options submitted to a Perl program on the command line are placed in @ARGV predefined variable. As the library parses the input it recognizes in @ARGV it removes those elements from it, and after it's done @ARGV remains with unnamed options (those that don't start with - nor directly follow one such). This allows us to pass yet other input, most often filenames, which we can then use directly out of @ARGV. (Otherwise they are just ignored.)
So if you wish to suppress any other input check that nothing is left in @ARGV after the library is done parsing it.
I use List::Util to avoid checking individuall all variables but please do so if you want to return to the user a specific message for faulty input.
I made all options lower case since capitalization in the question isn't consistent. Please adjust as needed.
† Parsing input by hand places a lot of burden on the programmer.
We need to devise a system that seems suitable for our purpose (may be hard to tell ahead of time) -- how are options split from the command-line? what about multiple words, special chars etc? for which shell is this? order -- positional? (error prone and very hard to check!) etc.
Then we need to parse it, anticipate and catch all manner of possible errors, possibly introduce some post-processing.
A lot of work, debugging and testing, iterations ... and the result is most likely brittle, so that when there is a change to make in the future the rest (or all of it?) may need reworking.
That's what libraries are for; all that, and more, is done.