http://www.perlmonks.org?node_id=871586


in reply to How do I code multiple failure modes for Data::FormValidator field validations?

zip:

Stricken as part of the update (below) because this is just plain wrong: Despite the title (and what I construe to be needless use of Data::FormValidator) /me thinks your problem is the attempt at comparison in your first sub.

Here's my stab at what I think (lacking code that does actually compile) you intend:

#!/usr/bin/perl # 871571 use strict; use warnings; my $num1 = 4; my $num2 = 4; my ($return1, $return2) = compare_num1_LT_num2($num1, $num2); print "\tBACK IN MAIN: \n"; { no warnings ("uninitialized"); if ($return1 eq 'NoWay') { print "\t $num1 is GT or EQUAL to $num2\n"; } else { print "\$return1: $return1 and \$return2: $return2\n\n"; } } print "Done\n\n"; sub compare_num1_LT_num2 { my ($first, $second) = @_; print "In sub compare... $first, $second\n"; if ( $first >= $second ) { return ('NoWay'); } else { return ( $first, $second ); } }

which returns

In sub compare... 4, 4 BACK IN MAIN: 4 is GT or EQUAL to 4 Done

Change $num1 to 3, and this is the output:

In sub compare... 3, 4 BACK IN MAIN: $return1: 3 and $return2: 4 Done

Lottsa' un-needed code and detail here... but that's the way my mind works (when it works).

Update (1712 EST): Based on exchange of msgs and a much needed bit of education (FROM thezip to /me), the compare...() returns 1 or 0, T or F, which is then supposed to be parsed by Data::FormValidator... meaning that portion of my reply (above) is probably most valuable as an object lesson to those ( points to self) who would mis-interpret a bit of legit syntax. Apologies.