Robert Monical wrote: > Hello > I'm maintaining a 4 year old mod_perl Web application. > > Several months ago, this list helped me to get the following working > > I spent a couple of hours last night trying to figure out if > there is a way to do this in a single statement. > > $val->{'Ammenities' } is set upstream and is a scalar > if a single item is selected, an array if more than one > is selected. > > To re-iterate, this code works. I just want to understand > if there is a better way. > > if (ref($val->{'Ammenities'}) eq "ARRAY"){ > for ( $keys = 0;$keys<=$#{$val->{Ammenities}};$keys++) { > $amen[$keys] = $val->{Ammenities}[$keys]; > }# end for > } else { > $amen[0] = $val->{Ammenities}; > }# end if > > Then we stick @amen in the database
Hi Robert Try: for ( $val->{'Ammenities'} ) { @amen = (ref) ? @$_ : ($_); } HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]