lib/TSQL/renumber-FormatFile.pl untested

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 88 CC 1 SCAR 6.9
CC
1
Cov
0%
END
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/bin/perl
2  
3 use Modern::Perl;
4 use strict;
5 use warnings;
6 use autodie qw(:all);
7 no indirect ':fatal';
8  
9 use Carp;
10  
11 use Readonly ;
12 use File::Basename;
13 use Smart::Comments;
14 use Try::Tiny;
15 use Getopt::Euclid qw( :vars<opt_> );
16 use Data::Dumper;
17  
18  
19 use version ; our $VERSION = qv('1.0.1');
20 our $opt_inputfile;
21 my $inputfile = $opt_inputfile;
22  
23 open(my $file, "<", $inputfile) or die "Could not open file $!";
24 #skip header
25 my @rows = <$file>;
26  
27 chomp $rows[0] ;say $rows[0];
28 chomp $rows[1] ;say $rows[1];
29 # 10 SQLCHAR 0 4 "" 10 modelintroduced SQL_Latin1_general_CP1_CI_AS
30 my $matchExp = qr/^ (\d+) (\s+SQLCHAR\s0\s+\d+\s+) ("[^"]*") (\s+) (\d+) (\s+)(\w+\s+SQL_Latin1_general_CP1_CI_AS\s*) $/x;
31 for my $li (0 .. scalar(@rows) -3){
32 chomp $rows[$li+2];#say $rows[$li+2];
33 my @matches = ($rows[$li+2] =~ m/$matchExp/);
34 # warn Dumper @matches;
35 my $firstadj = length($matches[0]) - length($li+1);
36 my $secondadj = length($matches[4]) - length($li+1);
37 #warn $secondadj;
38 say $li+1
39
40 #, " " ,$matches[0]
41 , ($firstadj>0?" "x$firstadj:"")
42 , ($firstadj<0?substr($matches[1],-$firstadj):$matches[1])
43 # , $matches[2]
44 , (($li != scalar(@rows) -3) ? '""' : '"\r\n"')
45 # , ($secondadj>0?" "x$secondadj:"")
46 # , (($li != scalar(@rows) -3) ? ($secondadj<0?substr(' ',-$secondadj):' ') : ($secondadj<0?substr(' ',-$secondadj):' '))
47 , (($li != scalar(@rows) -3) ? ' ' : ' ')
48 , $li+1
49 , ($secondadj>0?" "x$secondadj:"")
50 , ($secondadj<0?substr($matches[5],-$secondadj):$matches[5])
51 , $matches[6];
52 #my $col1 =
53 }
54 #warn Dumper @rows;
55  
56  
57 exit ;
58  
59 # #######################################################################################
60  
61  
62 END {
63 }
64  
65 __DATA__