in reply to Validating hash values

you need a combination of two of the replies:
foreach my $element ( keys %dateparts ) { die "No datepart!: $!" unless defined $dateparts{$element}; }

the 'exit' is redundant. if the code dies, the program is exiting.

i also don't think your assignment is going to work correctly. if you're passing in date values, you really should just use something like:

my %dateparts = @_;

assuming that your input args are in the form of:

sub MySQLIN( YEAR => '1999', DAY => '10', MONTH => '3');

the join will work even if the values to join are undefined.

Replies are listed 'Best First'.
RE: Re: Validating hash values
by tye (Sage) on Sep 16, 2000 at 03:23 UTC

    But if you don't initialize the hash, then passing in no arguments won't be properly detected, for example.

            - tye (but my friends call me "Tye")