Sudarshan Raghavan wrote: > > Sudarshan Raghavan wrote: > > > > ($ref_to eq 'ARRAY') && do { > > foreach my $arr_elem (@{$_}) { > > $arr_elem =~ s/^\s+//; > > $arr_elem =~ s/\s+$//; > > } > > last SWITCH; > > }; > > ($ref_to eq 'HASH') && do { > > foreach my $hash_val (%{$_}) { > > oops, the above statement should be > foreach my $hash_val (values (%{$_})) { > > > $hash_val =~ s/^\s+//; > > $hash_val =~ s/\s+$//; > > } > > last SWITCH; > > };
Actually the original will work. When you modify a hash like that in a foreach loop only the values but not the keys will be modified. $ perl -le' my %hash = ( " one " => " 1 ", " two " => " 2 " ); print "Before:"; print ">$_<" for %hash; s/^\s+//, s/\s+$// for %hash; print "After:"; print ">$_<" for %hash; ' Before: > one < > 1 < > two < > 2 < After: > one < >1< > two < >2< John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]