i've definitely solved the repetition problem! i'm not sure i can /see/ what "next;" is doing, but it does seem to be helping! haha.
i think my confusion now is, after doing all the other steps i can, i'm still not positive how to make the final if statement work: it's meant to be, "if user inputs none of the menu options, the invalid message appears". when i had it set to "if ($choice ne 'a'...'e')" then print the error message, but it seems like it's taking the input for $name1, etc, as an invalid input, too.
} if ($choice eq 'r'){ print "Enter a male name: "; chomp (my $name3 = lc <STDIN>); if (exists $son_father{$name3}) { print "Enter a new father name: "; chomp ($newname = <STDIN>); $son_father{$name3} = {$newname}; } else { print "Sorry, couldn't find you -- try again later!"; next; } } if ($choice ne 'a', 'r', 'o', 'd', 'e') { print "Invalid choice, TRY AGAIN!\n"; } }
i'm going to try and ask my professor about this more tomorrow, but i'm wondering if i'm just missing something obvious. will it read /every/ non-$choice standin as false if i write the if statement like this? is there any way to fix that? i thought assigning each standin a different variable would keep it separate from the if statement...
i'm definitely feeling less anxious after getting some help, but i'm getting pretty delirious after working on this for seven hours, hahah. sorry for being a bit incoherent.
oh, gosh, i forgot to say thank you. that's the problem with staying up until 4am. thank you so much!
In reply to Re^2: help with user selected hash operations?
by lunette
in thread help with user selected hash operations?
by lunette
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |