I need to achieve the following in perl
printmsg(@val1, $msg1) if @val1; printmsg(@val2, $msg2) if @val2; printmsg(@val3, $msg3) if @val3; printmsg(@val4, $m
You can't just string variables together like that and get a resulting variable. You COULD evaluate the expression of $msg + i, but it's probably better if you make msg an array and just index: $msg[$i].
$msg + i
$msg[$i]