|
Last change
on this file since 34 was
34,
checked in by markus, 7 years ago
|
|
Adding all debug tools and traces
|
-
Property svn:executable set to
*
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 | #!/usr/bin/perl -w |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | use 5.010; |
|---|
| 6 | use Getopt::Long qw(GetOptions); |
|---|
| 7 | Getopt::Long::Configure qw(gnu_getopt); |
|---|
| 8 | |
|---|
| 9 | ## $| = 1; |
|---|
| 10 | # |
|---|
| 11 | # Default settings |
|---|
| 12 | # |
|---|
| 13 | my $filename = '/dev/stdin'; |
|---|
| 14 | my $header; |
|---|
| 15 | my $verbose; |
|---|
| 16 | # |
|---|
| 17 | # Process command line options |
|---|
| 18 | # |
|---|
| 19 | GetOptions( |
|---|
| 20 | 'header|H' => \$header, |
|---|
| 21 | 'input|i=s' => \$filename, |
|---|
| 22 | 'verbose|v' => \$verbose, |
|---|
| 23 | ) or die "Usage: $0 [--header][--input <file>][--verbose]\n"; |
|---|
| 24 | # |
|---|
| 25 | # more parameters... |
|---|
| 26 | # |
|---|
| 27 | my $colCount = 0; |
|---|
| 28 | # |
|---|
| 29 | # Start processing... |
|---|
| 30 | # |
|---|
| 31 | open(my $fh, '<:encoding(UTF-8)', $filename) or die "Could not open file '$filename' $!"; |
|---|
| 32 | while (my $row = <$fh>) { |
|---|
| 33 | chomp $row; |
|---|
| 34 | next if (!$row); |
|---|
| 35 | # my @params = $row =~ /(?:^|\s+)((?:\S+):\s+(?:"[^"]*"|\S*))/g; |
|---|
| 36 | my @params = $row =~ /(?:^|\s+)((?:\S+):\s+(?:"[^"]*"|-?[0-9\.]+))/g; |
|---|
| 37 | if (scalar(@params)) { |
|---|
| 38 | next if ($colCount && ($colCount != scalar(@params))); |
|---|
| 39 | $colCount = scalar(@params); |
|---|
| 40 | my $headerLine = ""; |
|---|
| 41 | my $paramsLine = ""; |
|---|
| 42 | for (my $i=0; $i < scalar(@params); $i++) { |
|---|
| 43 | # print $i.": ".$params[$i]."\n"; |
|---|
| 44 | $params[$i] =~ /(\S+):\s+(.+)/; |
|---|
| 45 | if ($header) { |
|---|
| 46 | if ($i) { |
|---|
| 47 | $headerLine .= ";"; |
|---|
| 48 | } |
|---|
| 49 | $headerLine .= $1; |
|---|
| 50 | } |
|---|
| 51 | if ($i) { |
|---|
| 52 | $paramsLine .= ";"; |
|---|
| 53 | } |
|---|
| 54 | my $value = $2 =~ s/(-?[0-9]+)\.([0-9]+)/$1,$2/gr; |
|---|
| 55 | $paramsLine .= $value; |
|---|
| 56 | } |
|---|
| 57 | if ($header) { |
|---|
| 58 | print $headerLine."\n"; |
|---|
| 59 | undef $header; |
|---|
| 60 | } |
|---|
| 61 | print $paramsLine."\n"; |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.