Akron | 54c5221 | 2022-03-07 18:56:21 +0100 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | |
| 5 | our @ARGV; |
| 6 | |
| 7 | my $file = $ARGV[0]; |
Akron | 93ff869 | 2022-03-18 13:14:05 +0100 | [diff] [blame^] | 8 | my $file_name = $file; |
| 9 | $file_name =~ s!^.+?/([^/]+?)$!$1!; |
| 10 | |
| 11 | |
| 12 | my $out = $ARGV[1]; |
Akron | 54c5221 | 2022-03-07 18:56:21 +0100 | [diff] [blame] | 13 | |
| 14 | open(X, '<' . $file); |
Akron | 93ff869 | 2022-03-18 13:14:05 +0100 | [diff] [blame^] | 15 | unlink $file . '.raw'; |
| 16 | open(RAW, '>' . $out . '/' . $file_name . '.raw') or die $!; |
| 17 | unlink $file . '.split'; |
| 18 | open(SPLIT, '>' . $out . '/' . $file_name . '.split') or die $!; |
| 19 | unlink $file . '.eos'; |
| 20 | open(EOS, '>' . $out . '/' . $file_name . '.eos') or die $!; |
Akron | 54c5221 | 2022-03-07 18:56:21 +0100 | [diff] [blame] | 21 | |
| 22 | my $init; |
| 23 | |
| 24 | while(!eof(X)) { |
| 25 | local $_ = <X>; |
| 26 | |
| 27 | if (/^# text = (.+?)$/) { |
| 28 | if ($init) { |
| 29 | print SPLIT "\n"; |
| 30 | print RAW ' '; |
| 31 | }; |
| 32 | print RAW $1; |
Akron | 049e526 | 2022-03-18 09:59:34 +0100 | [diff] [blame] | 33 | my $temp = $1; |
| 34 | $temp =~ s/[\s\n\t]+//g; |
| 35 | print EOS $temp, "\n"; |
Akron | 54c5221 | 2022-03-07 18:56:21 +0100 | [diff] [blame] | 36 | } |
| 37 | elsif (m/^\d+[\s\t]/) { |
| 38 | if (/^\d+[\s\t]+([^\t\s]+)[\t\s]/) { |
| 39 | print SPLIT $1,"\n"; |
| 40 | $init = 1; |
| 41 | } |
| 42 | }; |
| 43 | }; |
| 44 | |
| 45 | close(X); |
| 46 | close(RAW); |
Akron | 049e526 | 2022-03-18 09:59:34 +0100 | [diff] [blame] | 47 | close(EOS); |
Akron | 54c5221 | 2022-03-07 18:56:21 +0100 | [diff] [blame] | 48 | close(SPLIT); |