M
Marek Stepanek
Hallo happy Perlers,
I have to bother you once again. I have a script with __DATA__ which will be
transformed later into a LaTeX Table. Just now I am stuck to insert these
DATA after a keyword "% begin", but I am not finding the solution.
Greetings from Munich,
marek
My LaTeX-Table "calc_hours_table02.tex" looks like follows:
\begin{longtable}[c]{| c | c | c | c | c | c | c | c |}
\hline
% \caption{table title}\\
\multicolumn{8}{| c |}{\textbf{TITLE}} \\
\hline
& & & \multicolumn{5}{ c |}{\textbf{title}} \\
\hline
\textbf{Datum} & \textbf{Umsatz 7\%} & \textbf{Umsatz 16\%} &
\textbf{Beginn} & \textbf{Pause} & \textbf{Ende} & \textbf{Stunden} &
\textbf{Km-Gesamt} \\
\hline
% begin <--- and here my script should insert the transformed data ...
\hline
\hline
\end
#!/usr/bin/perl
use strict;
use warnings;
####global variables########
my (@lines);
my ($date);
####END global variables####
#### Files #################
my $out_file = "calc_hours_table02.tex";
open OUT, "$out_file" or die "Error! $!\n;";
####END Files ##############
####Read in and work########
while (<DATA>)
{
chomp;
next if (/^$/);
if (/^(\w+, [\d\.]+)/)
{
$date = $1;
}
if (/^TOTAL/)
{
s/TOTAL/"$date"/e;
push (@lines, $_);
}
}
####END Read in and work####
####Output##################
while (<OUT>)
{
if (/^(% begin)$/)
{
s/(% begin)/"$1\n" . join ("\n",@lines)/e; ###And here my problem!
# print OUT "$1\n";
# print OUT join ("\n",@lines);
# print OUT "\n";
}
}
####END Output##############
######Data to read in#######
__DATA__
Son, 16.07.2006 37086.40 15445.00 808 19.50 3156.30
Mon, 17.07.2006 37667.00 15769.20 817 19.50 3621.00
TOTAL 580.60 324.20 9 0.00 464.70
Mon, 17.07.2006 37667.00 15769.20 817 19.50 3621.00
Die, 18.07.2006 37936.50 15929.60 823 19.50 3857.80
TOTAL 269.50 160.40 6 0.00 236.80
Die, 18.07.2006 37936.50 15929.60 823 19.50 3857.80
Mit, 19.07.2006 38147.50 16058.00 827 19.50 4042.80
TOTAL 211.00 128.40 4 0.00 185.00
Mit, 19.07.2006 38147.50 16058.00 827 19.50 4042.80
Don, 20.07.2006 38371.80 16188.60 833 19.50 4247.40
TOTAL 224.30 130.60 6 0.00 204.60
Don, 20.07.2006 38371.80 16188.60 833 19.50 4247.40
Fre, 21.07.2006 38607.70 16252.70 837 19.50 4359.20
TOTAL 235.90 64.10 4 0.00 111.80 55.00 166.80
Fre, 21.07.2006 38607.70 16252.70 837 19.50 4359.20
Sam, 22.07.2006 38752.70 16351.60 844 20.50 4523.90
TOTAL 145.00 98.90 7 1.00 164.70
Sam, 22.07.2006 38752.70 16351.60 844 20.50 4523.90
Son, 23.07.2006 38774.20 16351.60 844 20.50 4526.90
TOTAL 21.50 0.00 0 0.00 3.00
Son, 23.07.2006 38774.20 16351.60 844 20.50 4526.90
Mon, 24.07.2006 39056.90 16499.80 849 20.50 4740.60
TOTAL 282.70 148.20 5 0.00 213.70
Mon, 24.07.2006 39056.90 16499.80 849 20.50 4740.60
Die, 25.07.2006 39249.20 16574.60 853 20.50 4854.60
TOTAL 192.30 74.80 4 0.00 114.00
Die, 25.07.2006 39249.20 16574.60 853 20.50 4854.60
Mit, 26.07.2006 39249.20 16574.60 853 20.50 4854.60
TOTAL 0.00 0.00 0 0.00 0.00 55.00 55.00
Mit, 26.07.2006 39249.20 16574.60 853 20.50 4854.60
Don, 27.07.2006 39720.70 16762.90 864 21.50 5148.70
TOTAL 471.50 188.30 11 1.00 294.10
Don, 27.07.2006 39720.70 16762.90 864 21.50 5148.70
Fre, 28.07.2006 39932.00 16847.60 872 22.00 5289.80
TOTAL 211.30 84.70 8 0.50 141.10
Fre, 28.07.2006 39932.00 16847.60 872 22.00 5289.80
Sam, 29.07.2006 40002.60 16852.90 874 22.00 5307.00
TOTAL 70.60 5.30 2 0.00 17.20
Sam, 29.07.2006 40002.60 16852.90 874 22.00 5307.00
Son, 30.07.2006 40002.60 16852.90 874 22.00 5307.00
TOTAL 0.00 0.00 0 0.00 0.00
Son, 30.07.2006 40002.60 16852.90 874 22.00 5307.00
Mon, 31.07.2006 40224.40 16953.00 884 22.00 5485.40
TOTAL 221.80 100.10 10 0.00 178.40
I have to bother you once again. I have a script with __DATA__ which will be
transformed later into a LaTeX Table. Just now I am stuck to insert these
DATA after a keyword "% begin", but I am not finding the solution.
Greetings from Munich,
marek
My LaTeX-Table "calc_hours_table02.tex" looks like follows:
\begin{longtable}[c]{| c | c | c | c | c | c | c | c |}
\hline
% \caption{table title}\\
\multicolumn{8}{| c |}{\textbf{TITLE}} \\
\hline
& & & \multicolumn{5}{ c |}{\textbf{title}} \\
\hline
\textbf{Datum} & \textbf{Umsatz 7\%} & \textbf{Umsatz 16\%} &
\textbf{Beginn} & \textbf{Pause} & \textbf{Ende} & \textbf{Stunden} &
\textbf{Km-Gesamt} \\
\hline
% begin <--- and here my script should insert the transformed data ...
\hline
\hline
\end
#!/usr/bin/perl
use strict;
use warnings;
####global variables########
my (@lines);
my ($date);
####END global variables####
#### Files #################
my $out_file = "calc_hours_table02.tex";
open OUT, "$out_file" or die "Error! $!\n;";
####END Files ##############
####Read in and work########
while (<DATA>)
{
chomp;
next if (/^$/);
if (/^(\w+, [\d\.]+)/)
{
$date = $1;
}
if (/^TOTAL/)
{
s/TOTAL/"$date"/e;
push (@lines, $_);
}
}
####END Read in and work####
####Output##################
while (<OUT>)
{
if (/^(% begin)$/)
{
s/(% begin)/"$1\n" . join ("\n",@lines)/e; ###And here my problem!
# print OUT "$1\n";
# print OUT join ("\n",@lines);
# print OUT "\n";
}
}
####END Output##############
######Data to read in#######
__DATA__
Son, 16.07.2006 37086.40 15445.00 808 19.50 3156.30
Mon, 17.07.2006 37667.00 15769.20 817 19.50 3621.00
TOTAL 580.60 324.20 9 0.00 464.70
Mon, 17.07.2006 37667.00 15769.20 817 19.50 3621.00
Die, 18.07.2006 37936.50 15929.60 823 19.50 3857.80
TOTAL 269.50 160.40 6 0.00 236.80
Die, 18.07.2006 37936.50 15929.60 823 19.50 3857.80
Mit, 19.07.2006 38147.50 16058.00 827 19.50 4042.80
TOTAL 211.00 128.40 4 0.00 185.00
Mit, 19.07.2006 38147.50 16058.00 827 19.50 4042.80
Don, 20.07.2006 38371.80 16188.60 833 19.50 4247.40
TOTAL 224.30 130.60 6 0.00 204.60
Don, 20.07.2006 38371.80 16188.60 833 19.50 4247.40
Fre, 21.07.2006 38607.70 16252.70 837 19.50 4359.20
TOTAL 235.90 64.10 4 0.00 111.80 55.00 166.80
Fre, 21.07.2006 38607.70 16252.70 837 19.50 4359.20
Sam, 22.07.2006 38752.70 16351.60 844 20.50 4523.90
TOTAL 145.00 98.90 7 1.00 164.70
Sam, 22.07.2006 38752.70 16351.60 844 20.50 4523.90
Son, 23.07.2006 38774.20 16351.60 844 20.50 4526.90
TOTAL 21.50 0.00 0 0.00 3.00
Son, 23.07.2006 38774.20 16351.60 844 20.50 4526.90
Mon, 24.07.2006 39056.90 16499.80 849 20.50 4740.60
TOTAL 282.70 148.20 5 0.00 213.70
Mon, 24.07.2006 39056.90 16499.80 849 20.50 4740.60
Die, 25.07.2006 39249.20 16574.60 853 20.50 4854.60
TOTAL 192.30 74.80 4 0.00 114.00
Die, 25.07.2006 39249.20 16574.60 853 20.50 4854.60
Mit, 26.07.2006 39249.20 16574.60 853 20.50 4854.60
TOTAL 0.00 0.00 0 0.00 0.00 55.00 55.00
Mit, 26.07.2006 39249.20 16574.60 853 20.50 4854.60
Don, 27.07.2006 39720.70 16762.90 864 21.50 5148.70
TOTAL 471.50 188.30 11 1.00 294.10
Don, 27.07.2006 39720.70 16762.90 864 21.50 5148.70
Fre, 28.07.2006 39932.00 16847.60 872 22.00 5289.80
TOTAL 211.30 84.70 8 0.50 141.10
Fre, 28.07.2006 39932.00 16847.60 872 22.00 5289.80
Sam, 29.07.2006 40002.60 16852.90 874 22.00 5307.00
TOTAL 70.60 5.30 2 0.00 17.20
Sam, 29.07.2006 40002.60 16852.90 874 22.00 5307.00
Son, 30.07.2006 40002.60 16852.90 874 22.00 5307.00
TOTAL 0.00 0.00 0 0.00 0.00
Son, 30.07.2006 40002.60 16852.90 874 22.00 5307.00
Mon, 31.07.2006 40224.40 16953.00 884 22.00 5485.40
TOTAL 221.80 100.10 10 0.00 178.40