I'm echoing terdons plea to not prompt the user interactively without reason. In this case, it's easier for the user to give the strings as arguments to a script since it gives them the option of recalling the command from the shell's command-line history or using the shell's tab completion, general editing capabilities, etc.
The below script uses a single awk command.
The awk command takes the given strings as its command-line arguments, and formats each of them individually in a loop. The purpose of the loop is to build a record of fields, each field being some string PkgN=something where N is an integer counter and something is one of the given strings.
When the loop is finished, print outputs the completed record. The delimiter assigned to OFS is used between the fields.
#!/bin/sh
awk -v OFS=, '
BEGIN {
for (i = 1; i < ARGC; ++i) $i = sprintf("Pkg%d=%s", i, ARGV[i])
print
}' "$@"
The same idea, but using a shell loop:
#!/bin/sh
i=0
for pkg do
i=$(( i + 1 ))
set -- "$@" "Pkg$i=$pkg"
shift
done
IFS=,
printf '%s\n' "$*"
This replaces each of the positional parameters (the arguments to the script) with the new string and ends with printing them all with commas as delimiters.
Both of these scripts would output an empty line if no arguments are given. You may avoid that by testing for arguments at the start of the script and exiting if there are none:
[ "$#" -ne 0 ] || exit
The way the test is done here would ensure that the script is terminated with a non-zero exit status if it's called with no arguments.
Testing:
$ ./script perl runtime pool tools
Pkg1=perl,Pkg2=runtime,Pkg3=pool,Pkg4=tools