code cleanup
lima1
13 years ago
7 | 7 | |
8 | 8 | use version; our $VERSION = qv('1.0.6'); |
9 | 9 | |
10 | my $line_id = 0; | |
11 | 10 | my @input; |
12 | my $paramline; | |
13 | 11 | |
14 | 12 | while ( my $line = <> ) { |
15 | 13 | chomp $line; |
16 | $line =~ s{\s+}{ }xmsg; | |
14 | ||
15 | # remove leading and trailing blanks | |
17 | 16 | $line =~ s{\A \s* | \s* \z}{}xmsg; |
18 | 17 | |
19 | 18 | # remove trailing \\, we do that later |
20 | 19 | $line =~ s{\A \\\\ \z}{}xmsg; |
21 | 20 | |
22 | if ( $line_id == 0 ) { #first line contains the parameters | |
23 | $paramline = $line; | |
24 | } | |
25 | else { | |
26 | push @input, $line; | |
27 | } | |
28 | $line_id++; | |
21 | push @input, $line; | |
29 | 22 | } |
30 | 23 | |
31 | 24 | # remove trailing empty lines |
34 | 27 | } |
35 | 28 | |
36 | 29 | # uncomment original input |
37 | _say( join q{}, map {"\n % $_"} ( $paramline, @input ) ); | |
30 | _say( join q{}, map {"\n % $_"} ( @input ) ); | |
31 | ||
32 | my $paramline = shift @input; | |
38 | 33 | |
39 | 34 | # create rows/column array[array_ref], remove leading and trailing spaces |
40 | 35 | @input = map { |
45 | 40 | my %params = map { _parse_param($_) } split m{ ; }xms, $paramline; |
46 | 41 | |
47 | 42 | my $table = LaTeX::Table->new( |
48 | { header => [ $input[0] ], | |
49 | data => [ @input[ 1 .. $#input ] ], | |
43 | { header => [ shift @input ], | |
44 | data => \@input, | |
50 | 45 | %params, |
51 | 46 | } |
52 | 47 | ); |