in reply to Passing a value from a module
You could just arrange your interface to return error messages as well as the 'cleaned' value.
sub numbers { my ($class,$number) = @_; if ( /(\d+)/ ) { return ( $1, { msg => 'ok' } ); } else { return ( undef, { msg => 'numbers, please' } ); } } ... my ($age,$stuff) = Validate->numbers( ... ); unless ( $age ) { push @errors, $stuff->{msg}; }
Also, I know this is just example code, but your regex to validate numbers isn't very solid. You'd be much better off with Regexp::Common.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Passing a value from a module
by bradcathey (Prior) on Apr 15, 2004 at 13:42 UTC | |
by qq (Hermit) on Apr 15, 2004 at 19:58 UTC |