in reply to Re: Passing a value from a module
in thread Passing a value from a module

qq thanks for your reply. It worked wonderfully. In fact, I adapted it to have better messages:
sub numbers { my ($class, $value, $len) = @_; if (!$value) { return (undef, { msg => 'cannot be blank.' }); } elsif (length($value) > $len ) { return (undef, { msg => 'has too many characters.' }); } elsif ($value !~ /^([0-9 \.-]*)$/) { return (undef, { msg => 'can only use numbers.' }); } else { return ("$1", { msg => '' }); } }

—Brad
"A little yeast leavens the whole dough."

Replies are listed 'Best First'.
Re: Re: Re: Passing a value from a module
by qq (Hermit) on Apr 15, 2004 at 19:58 UTC

    Careful about your tests, though. 0 isn't true, so you'll get the "cannot be blank" message. And /^([0-9 \.-]*)$/ would match '.-.. ', '--0.0.3....' , ' - ', etc.

    qq