$prompt = "-RN- (-LOC-)"; @user_info = ("juser", "Joe", "3rd floor"); # Here would be some code to do create the sprintf format and # determine the appropriate array slices # $patten is determined to be "%s (%s)" and $slices is determined # to be "1,2"; my $output = sprintf($pattern, @user_info[$slices]);