template 1: <%= my $capi = ''; if (@{$ctxt{'capi_devices'}}){ $capi = 'afu_op=grpcapp' . "\n" . 'capp=1' . "\n" . 'icnt=200' . "\n" . 'capi_dev=' . join(' ', @{$ctxt{'capi_devices'}})."\n". 'capi_cards=' . @{$ctxt{'capi_devices'}}; } $capi; %> <%= my $marega = ''; if (@{$ctxt{'test'}}){ $marega = 'splthid=' . join(' ' ,@spthid_a). "\n" . 'splthjobops=' . join(' ', @{$ctxt{'test'}}). "\n" ; } $marega; %> #### while($inp =~ /<%=(.*?)%>/s) { print "Dollar 1 before eval = $1\n"; $inp =~ s/<%=(.*?)%>/eval $1/es; print"INP after substitution = $inp\n"; } # only the concerned part of code with this extraction is written here #### Dollar 1 before eval = my $capi = ''; if (@{$ctxt{'capi_devices'}}){ $capi = 'afu_op=grpcapp' . "\n" . 'capp=1' . "\n" . 'afusched=1 1 1 0 0 0 0 0' . "\n" . 'afu_type=1 1 1 0 0 0 0 0' . "\n" . 'icnt=200' . "\n" . 'capi_dev=' . join(' ', @{$ctxt{'capi_devices'}})."\n". 'capi_cards=' . @{$ctxt{'capi_devices'}}; } $capi; INP after substitution = splthid=7 splthjobops=0 2 1 1 4 0 2 6 0 3 8 0 4 0 0 # here i expect the $1 contents after evaluation to come that is $capi should be printed but instead $marega is executed.