in reply to Regex error in the second last string

haukex (++) is right - the evaluation depends on the contents of
$ctxt{'capi_devices'}
I was able to get "expected output" after setting:
$ctxt{capi_devices}=["CAPI DEVICE"];
The value of $inp (After first iteration) was:
afu_op=grpcapp capp=1 icnt=200 capi_dev=CAPI DEVICE capi_cards=1 <%= my $marega = \'\'; if (@{$ctxt{\'test\'}}){ $marega = \'splthid=\' . join(\' \' ,@spthid_a). "\\n" . \'splthjobops=\' . join(\' \', @{$ctxt{\'test\'}}). "\\n" ; } $marega; %>

        ...it is unhealthy to remain near things that are in the process of blowing up.     man page for WARP, by Larry Wall