At 10:18 AM 11/27/2001 +1030, Daniel Falkenberg wrote: >Hey all, > >Once again I feel as if the following code is far too long and can >easily be shortened. Could some one give me some ideas on doing this? > >foreach my $U (sort keys %PASS) { > $PASS{$U}{'fname'} = ""; > $PASS{$U}{'lname'} = ""; > $PASS{$U}{'user'} = ""; > $PASS{$U}{'password'} = ""; >} > >Of coarse all the above does is reset the hash values (%PASS) to equal >nothing. I am pretty sure I can do this alot easier.]
If all you want to do is reset the values of the entire hash, you can just undef the hash, or reset it like this: %pass = (); If you need to reset specific keys, then try something like this: my @reset_keys = ('fname', 'lname', 'user', 'password'); foreach my $reset_key (@reset_keys) { foreach my $U (keys %PASS) { $PASS{$U}{$reset_key} = undef; } } HTH..aloha mel -- mel matsuoka [EMAIL PROTECTED] Head Geek (vox)1.808.531.5474 Hawaiian Image Productions (fax)1.808.526.4040 http://hawaiianimage.com > >Also does the following have to be written like so? > >$new_user = $PASS{$PASSWD_NAME}{'user'}; >$new_pass = $PASS{$PASSWD_NAME}{'password'}; >$new_fname = $PASS{$PASSWD_NAME}{'fname'}; >$new_lname = $PASS{$PASSWD_NAME}{'lname'}; > >Do I have to declare each hash value like the above. Of coarse I want >to be able to still declare a variable to each hash value that I want > >Does any one have any ideas on this? > >Thx in advance, > >Dan > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]