in reply to Re: Retrieving "msgs" values from Data::FormValidator
in thread Retrieving "msgs" values from Data::FormValidator
I'm glad to see that you are on the right track. What you need to learn now is how to deal with references and data structures in perl. I would recommend that you read the references tutorial here on PerlMonks to get you familiar with how to access data structures in perl.
Now, back to D::FV. From the docs it says that the msgs method returns a hash reference. So in order to access the data you will need to know how to de-reference that hash. The folowing code should be able to print out your messages:
my $messages = $results->msgs(); # $messages now contains a hashref # The arrow operator de-references the hashref print "input two: ", $messages->{two}, $/; print "input three: ", $messages->{three}, $/; # Or de-reference it first and then print my %messages_hash = %$messages; print "input two: ", $messages_hash{two}, $/; print "input three: ", $messages_hash{three}, $/; # Or print out everything in messages while (my($key, $value) = each %$messages) { print "input $key: $value$/"; }
I have not tested the above code, but if msgs does return a hash reference then it should work.
Hope this helps...
- Cees
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Retrieving "msgs" values from Data::FormValidator
by Hagbone (Monk) on Dec 21, 2003 at 20:14 UTC |