|One way is to use the set command to parse the string where each segment is set to one of the command line variables and the total number of variables is $#|
Warning: I haven't tested it, but you might have a problem if you have 10 or greater variables.
Let me know if you have any questions:
set $(IFS="_"; echo $str)
###echo $# # number of variables should be 4
# create var1 to var4
while (($i <= $nv))
# display variables var1 to var4
while (($h <= $nv))
eval echo \"\$var$h\"