my ($server,$db_type,$server_location,$server_function); my @servers; while (1) { system("clear"); print "\t\t\tPLEASE CHOOSE AN OPTION FROM BELOW\n"; print <<EOF; (1) Server Name: $server (2) Database Type: $db_type (3) Server Location: $server_location (4) Server Function: $server_function ------------------------------------------- (A) Add Another Server (C) Continue (D) Done * - item is optional. EOF print "Enter the number you would like to edit > "; chomp( my $choice = <STDIN> ); if ( $choice == 1 ) { print "Please enter the server name: "; chomp( $server = <STDIN> ); } elsif ( $choice == 2 ) { print "Please enter the database type: "; chomp( $db_type = <STDIN> ); } elsif ( $choice == 3 ) { print "Please enter the server location: "; chomp( $server_location = <STDIN> ); } elsif ( $choice == 4 ) { print "Please enter the server function: "; chomp( $server_function = <STDIN> ); } elsif ( $choice =~ /a/i ) { push(@servers,"$server,$db_type,$server_location,$server_f +unction); $server=""; $db_type=""; $server_location=""; $server_function=""; } elsif ( $choice =~ /c/i ) { push(@servers,"$server,$db_type,$server_location,$server_f +unction); last; } else { next; } } ..... # later in the code for my $server (@servers) { my ($server,$db_type,$server...)=split(',',$server); do stuff; }
In reply to Hash vs. Scalar+Text vs. DBD by walkingthecow
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |