Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从perl创建灵活的latex表_Perl_Latex - Fatal编程技术网

从perl创建灵活的latex表

从perl创建灵活的latex表,perl,latex,Perl,Latex,我有一个从数据库输出每月统计数据的perl脚本。使用以下代码片段在表中总结这些内容 print $fh <<END; This report details clinical and imaging statistics from $date_start to $date_stop. \\large \\bf Clinical Statistics \\normalsize \\rm \\begin{table}[h] \\centering \\begin{tabula

我有一个从数据库输出每月统计数据的perl脚本。使用以下代码片段在表中总结这些内容

print $fh <<END; 
This report details clinical and imaging statistics from $date_start to $date_stop.

\\large \\bf Clinical Statistics

\\normalsize \\rm 

\\begin{table}[h]
\\centering 
\\begin{tabular}{p{4cm}cccccccc} 
\\hline
  & $operator[0] & $operator[1] & $operator[2] & $operator[3] & $operator[4] & $operator[5] & $operator[6] & $operator[7] \\\\
\\hline

    Cannulations & $venflons[0] & $venflons[1] & $venflons[2] & - & $venflons[4] & $venflons[5] & $venflons[6] & $venflons[7] \\\\
    Clinical Assessments & $clin_ass[0] & $clin_ass[1] & $clin_ass[2] & - & $clin_ass[4] & $clin_ass[5] & $clin_ass[6] & - \\\\
    Lead Stressor & $etlead[0] & $etlead[1] & $etlead[2] & - & $etlead[4] & $etlead[5] & $etlead[6] & $etlead[7] \\\\
    Assistant Stressor & $etass[0] & $etass[1] & $etass[2] & - & $etass[4] & $etass[5] & $etass[6] & - \\\\
    ECG Preparation & $ecg_prep[0] & $ecg_prep[1] & $ecg_prep[2] & $ecg_prep[3] & $ecg_prep[4] & $ecg_prep[5] & $ecg_prep[6] & - \\\\Patient Identification & $patient_id[0] & $patient_id[1] & $patient_id[2] & $patient_id[3] & $patient_id[4] & $patient_id[5] & $patient_id[6] & - \\\\
    \\hline
    \\end{tabular}
    \\end{table}

    END

print$fh您可以使用
join

print '&', join('&', @operator), '\\';

定义一个打印行的函数

sub print_row
{
    my($fh) = shift;
    print $fh join(' & ', @_), "\\\\\n";
}
此函数将一行打印到
$fh
,该行由
print\u row
的所有参数组成。如果您想打印更多的列,只需提供更多的参数

现在在你的桌子上用这个

print $fh <<END; 
This report details clinical and imaging statistics from $date_start to $date_stop.

\\large \\bf Clinical Statistics

\\normalsize \\rm 

\\begin{table}[h]
\\centering 
\\begin{tabular}{p{4cm}cccccccc} 
\\hline
END

print_row($fh, '', @operator);
print $fh "\\hline\n";
print_row($fh, 'Cannulations', @venflons, '-');
print_row($fh, 'Clinical Assessments', @clin_ass, '-');
print_row($fh, 'Lead Stressor', @etlead);
print_row($fh, 'Assistant Stressor', @etass, '-');
print_row($fh, 'ECG Preparation', @ecg_prep, '-');
print_row($fh, 'Patient Identification', @patient_id, '-');

print $fh <<END; 
\\hline
\\end{tabular}
\\end{table}

END

print$fh在printrow函数中添加破折号分隔每三项

#inserts dash if no remainder from division of four of the array index  
for (0..$#columns){
splice(@columns,$_,0,'-') unless ($_ % 4)
}
在打印语句之前


郊狼

可能使用乳胶模块?例如。我如何更新表中的列数-\\begin{tabular}{p{4cm}cccc}@moadeep只需添加更多的
c
s、
l
s和/或
r
s,然后用正确的列数填充适当的数组。根据需要添加或保留
'-'
。我还注意到,
print\u row
可以简化一点。请参阅更新的答案。