| rupert@melbourne 2006-04-07, 3:55 am |
| Hello all, i'm using XML::Simple; and have created a hash with scalar
values that may either be a value or reference to an array with scalar
values. as seen below;
'JigsawWyla' => {
'images' => {
'thumbScreens' => {
'screen' => '<img
src="http://www.sites.com/jigwyland_screen_01_sm.jpg" />'
},
},
'Scrabble' => {
'images' => {
'thumbScreens' => {
'screen' => [
'<img src="http://www.sites.com/scrabble_thumb_01.jpg"
/>',
'<img src="http://www.sites.com/scrabble_thumb_02.jpg"
/>',
'<img src="http://www.sites.com/scrabble_thumb_03.jpg"
/>',
'<img src="http://www.sites.com/scrabble_thumb_04.jpg"
/>'
]
},
},
if I type:
print $games->{JigsawWyla}->{images}->{thumbScreens}->{screen};
it returns;
<img
src="http://www.gamehouse.com/i/jigsaw/screenshots/jigwyland_screen_01_sm.
/>
however if I type;
print $games->{Scrabble}->{images}->{thumbScreens}->{screen};
it returns
ARRAY(0x1b80198)
I wish to handle the senario in such a way with an if statement such
that if it is case (a)
I will simply print the output like it is. however if it is case (b) I
wish to run a foreach loop to print out the values of the refenced
array.
Problem is...
if (exists($games->{JigsawWyla}->{images}->{thumbScreens}->{screen}))
won't work because it does exist in some shape but it can't determine
if it's a reference or the thing I want to print in the first place.
HELP!
|