On Tue, Nov 27, 2001 at 10:18:23AM +1030, Daniel Falkenberg wrote: > foreach my $U (sort keys %PASS) {
Why are you sorting them? As far as your code is concerned it doesn't matter what order you get them in, so it's pointless to sort it. > $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.] It depends on your needs. If it doesn't matter that the keys exist, and there are no other keys in the sub-hash that matter: %$_ = () foreach values(%PASS); > 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'}; Does it have to be? Well, no, but that's probably the most readable for what you want out of it. I might suggest keeping the hash around, but decreasing the number of dereferences: %new = %{ $PASS{$PASSWD_NAME} }; Then use $new{'user'} instead of $new_user, $new{'password'} instead of $new_pass, etc. > 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 Which above, the foreach, or the '$new_user = ...' assignments? You don't have to declare hash keys to use them, and in fact you weren't declaring your hash keys in any of your code; you were assigning values to them. For that matter, there is no syntax for simply declaring hash keys, you have to initialize them. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]