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
    my $messages = $results->msgs(); # $messages now contains a hashref
    I guess that's where my brain cramp was .... following your example allowed me to access the values - thanks very much.

    I think the trouble I'm having coming up to speed is wrapping my brain around the various forms of data ... for some reason, items such as %$message are still un-intuitive for me.

    >I would recommend that you read the references tutorial here on PerlMonks to get you familiar with how to access data structures in perl.

    I certainly will (probably numerous times) ... sometimes it's difficult to know what to read when you don't know what you need ;).

    I've got a feeling that when it finally becomes clear, it will be in a threshold way, and I'll find myself wondering why it took me so long to grasp it.