in reply to Menu Troubles..

Your code could be greatly simplified with the use of a couple of arrays and a hash.

Try something like this. (UNTESTED)

my %hash; my @hashkey = qw(fname lname school phone position role pass); my @query = ('First Name','Last Name','The School you work at', etc... +. ); my $number = 0; while ($number < 8) { system "cls"; print "You have entered these Values for each of these fields."; print "If you wish to Fix any of the information now. Select Number +to Change:\n"; print "\t1. $query[0]: $hash{$hashkey[0]\n"; print "\t2. $query[1]: $hash{$hashkey[1]\n"; .. .. print "\t8. Done\n"; print "Type a number to Choose to fix: "; $number = <STDIN>; if ($number < 8 ) { system "cls"; while ($hash{$hashkey[$number]} eq "") { printf "\n\nPlease Enter your $query[$number]: "; $hash{$hashkey[$number]} = <STDIN>; chomp($hash{$hashkey[$number]}); } } } exit;

Replies are listed 'Best First'.
Re^2: Menu Troubles..
by Tanktalus (Canon) on Jun 15, 2005 at 23:12 UTC

    I usually go a step further. I don't like having two related lists which aren't in the same data structure. So something like this:

    my @data = ( { query => 'First Name', }, { query => 'Last Name', }, # etc. ); while (1) { system("cls"); print "You have entered these values for each of these fields.\n", "If you wish to fix any of the information now, select the num +ber to change\n"; for (my $i = 0; $i < scalar @data; ++$i) { print "\t", $i + 1, ". ", $data[$i]{query}, ": ", $data[$i]{value} +||"", "\n"; } print "\t0. Done\n"; print "Type a number to choose to change: "; my $number = <STDIN>; chomp($number); if ($number == 0) { last; } --$number; print "\n\nPlease enter your ", $data[$number]{query}, ": "; $data[$number]{value} = <STDIN>; chomp($data[$number]{value}); }

    (Also untested.)

      Thanx Tanktalus This works fine what type of array is that?
        It's an Array of Hashes (AoH). See perldsc for more info on embedding arrays within hashes, hashes within arrays, arrays within arrays, and hashes within hashes.