in reply to Testing Complex Data Structures
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:if (ref $data->{foo} eq "ARRAY") { # list } else { # single message }
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 |