#!/usr/bin/perl -l $dialog->{attributes}{control1} = "abc"; $dialog->{attributes}{control2}[0] = "cde"; $dialog->{attributes}{control2}[1] = "fgh"; for my $control (keys %{ $dialog->{attributes} }) { if (ref $dialog->{attributes}{$control} eq 'ARRAY') { print "@{ $dialog->{attributes}{$control} }"; } else { print $dialog->{attributes}{$control}; } } __END__ abc cde fgh #### for my $control (keys %{ $dialog->{attributes} }) { my $val = $dialog->{attributes}{$control}; if (ref $val eq 'ARRAY') { print "@$val"; } else { print $val; } } #### ... } elsif (!ref $val) { print $val; }