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 < "; chomp( my $choice = ); if ( $choice == 1 ) { print "Please enter the server name: "; chomp( $server = ); } elsif ( $choice == 2 ) { print "Please enter the database type: "; chomp( $db_type = ); } elsif ( $choice == 3 ) { print "Please enter the server location: "; chomp( $server_location = ); } elsif ( $choice == 4 ) { print "Please enter the server function: "; chomp( $server_function = ); } elsif ( $choice =~ /a/i ) { push(@servers,"$server,$db_type,$server_location,$server_function); $server=""; $db_type=""; $server_location=""; $server_function=""; } elsif ( $choice =~ /c/i ) { push(@servers,"$server,$db_type,$server_location,$server_function); last; } else { next; } } ..... # later in the code for my $server (@servers) { my ($server,$db_type,$server...)=split(',',$server); do stuff; }