There are 2 things you should be doing to make the code easier to understand and maintain. #1 is the logical use of blank lines to separate different concepts and proceses.
Illogical spacing:
open('conf', "$PATHconf") || die "can't open $PATHconf: $!\n";
my @conf = <conf>;
close('conf');
my $i=0;
foreach(@conf){
my $line = $conf[$i];
my $t= "".$i;
my $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$
+VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
my $rowCount = 0;
my $filename = "Output012023.xlsx";
my $workbook = Excel::Writer::XLSX->new( $filename );
open(FH, "<", "Debt.csv" ) or die;
Logical spacing:
open('conf', "$PATHconf") || die "can't open $PATHconf: $!\n";
my @conf = <conf>;
close('conf');
my $i=0;
foreach(@conf){
my $line = $conf[$i];
my $t = "".$i;
my $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$
+VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
my $rowCount = 0;
my $filename = "Output012023.xlsx";
my $workbook = Excel::Writer::XLSX->new( $filename );
open(FH, "<", "Debt.csv" ) or die;
#2 is to add a comment every time you figure something out:
foreach(@conf){
my $line = $conf[$i];
# the reason for doing this weird thing
my $t. = "".$i;
The comments will significantly reduce the cognitive load needed to comprehend the code by outsourcing all the reasons for this and that to brief human readable comments.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.