in reply to Re: Menu Troubles..
in thread Menu Troubles..

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.)

Replies are listed 'Best First'.
Re^3: Menu Troubles..
by Snowman11 (Novice) on Jun 24, 2005 at 16:23 UTC
    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.
        awesome thanks for your quick response this site owns