Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: How do I code multiple failure modes for Data::FormValidator field validations?

by ww (Archbishop)
on Nov 15, 2010 at 21:46 UTC ( #871586=note: print w/replies, xml ) Need Help??

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


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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://871586]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2018-06-23 01:10 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.