I want to validate a condition before doing the next step, but only raise a warning and skip the current value instead of die-ing.
How do I rewrite validate_me() subroutine without returning any value?
(Update) please note that the following code works as expected, it just that I want something else instead of returning 1 or 0 from validate_me() that still allow the code to behave the same.
foreach my $file ( @files ) {
validate_me($foo, $bar, $baz) or next;
do_something();
}
sub validate_me {
my ($foo, $bar) = @_;
if ( $foo > $bar ) {
carp("Something goes awol");
return 0;
}
if ( $bar != $baz ) {
carp("Odd");
return 0;
}
return 1; # success
}
Thanks.