I have a text file containing 2 exec statements as below and trying to store the below 2 execs into 2 different scalar variables in perl.
/* ICD Dist, Total */ /* need to export to Excel, sheet=ICD_Dist__Total */
exec(
'select sum(count(*))
cast(count(*)*100.0/sum(count(*)) over() as decimal(18,2)) as percent_total
from DETAIL_' + @dataset_id + '
)
/* ICD Dist, by Month */ /* need to export to Excel */
exec(
'select serv_yrmo_tot_claims,
cast(count(*)*100.0/sum(count(*)) over(partition by left(convert(varchar,SERVICE_DT,112),6)) as decimal(18,2)) as percent_per_mth
from DETAIL_' + @dataset_id + '
)
final output should be like
$query1 = 'exec(
'select sum(count(*))
cast(count(*)*100.0/sum(count(*)) over() as decimal(18,2)) as percent_total
from DETAIL_' + @dataset_id + '
)'
$query2 = 'exec(
'select serv_yrmo_tot_claims,
cast(count(*)*100.0/sum(count(*)) over(partition by left(convert(varchar,SERVICE_DT,112),6)) as decimal(18,2)) as percent_per_mth
from DETAIL_' + @dataset_id + '
)'
tried with few possible regex but couldn't able to make it.
Could anyone please help out in solving this.
Hi scriptscript,
You said you had code that was close to working, but you needed help with the REs. Since the code Ranga and looney suggested doesn't meet your needs, please show us what you have tried and maybe we can then help you tweak your code get what you want.
The query strings are already a scalar each time through the loop, they are called $line
If my guess is correct you want to use that $line to execute the query via a system call. Unfortunately, that would be wrong in many ways, and it would take a lot of explanation.