in reply to How to make check process more elegant

Assuming that the number of checks you wish to do is actually larger than your example, I would code each check as a separate subroutine and use a dispatch table. For example:
sub CheckFile { my $filename = shift; ... } sub CheckHost { my $host = shift; ... } sub CheckDB { my $db = shift; ... } ... my %checkList = ( DbName => \&CheckDB, configFile => \&CheckFile, iniFile => \&CheckFile, remoteHOST => \&CheckHost ); while (my($key,$value) = each %checkList) { &$value($key) or die "Check $key failed"; }
This would enable you to add many more checks, and to factor our those checks in common. You might wish to change the design of the hash if the entities are not unique, or if you wish to do more than one check on each item. You could place the checking subroutines in their own module and reuse across several scripts.