John Ross wrote: > > I am trying to pass an already existing hash into a subroutine, modify > that hash, and have the modifications "take" when I leave the subroutine. > I have looked through a number of perl books, but I either don't know what > I am looking for, or I just don't understand how this works. I am > assuming that you pass the hash into the sub by reference, but from there, > what? > When I modify the hash, the changes don't take. I don't want to "return" > the hash, as I don't wan't another copy. Help!
sub mod_hash { my $hash_ref = shift; $hash_ref->{'two'} = 222; for my $key ( keys %$hash_ref ) { if ( $key eq 'three' ) { $hash_ref->{ $key } = 333; } } } my %hash = ( one => 1, two => 2, three => 3 ); mod_hash \%hash; perldoc perlreftut perldoc perlref perldoc perlsub perldoc perldata perldoc perldsc John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]