in reply to Testing Complex Data Structures

You need to test whether the ref value of $data->{foo} is an arrayref: if so, it's a list of messages; otherwise it's a single message. And that's pretty easy:
if (ref $data->{foo} eq "ARRAY") { # list } else { # single message }
What I sometimes like to do in such situations--where I can have either an arrayref or a single value--is coerce the single value into an array ref. Then I can use the same code to deal with both situations:
unless (ref $data->{foo} eq "ARRAY") { $data->{foo} = [ $data->{foo} ]; }

Replies are listed 'Best First'.
(tye)Re2: Testing Complex Data Structures
by tye (Sage) on Feb 26, 2001 at 22:38 UTC

    Just a note that the ref() check will fail if the array is blessed while using UNIVERSAL::isa() doesn't have this problem (even though it is uglier code). I'll leave the choice of which consideration is more important in this case up to personal preference.

            - tye (but my friends call me "Tye")