Use Dynamic Values in array

Need to use dynamic values in script processor for better results , but its always giving error. Kindly help!!!!

"processors": [
{
"split": {
"field": "f1",
"separator": "_",
"target_field":"temp"
},
"script": "ctx.ln=ctx.temp.length ;ctx.f2 = ctx.temp[ln-2]; ctx.f3= ctx.temp[ln-1]",
"remove": {
"field": "temp"
}
}

]