Perl debugger has wrong initial entry point and line numbers

L

luke_airig

UNIX SunOS 5.8, Perl version 5.003

When I invoke the Perl debugger on the following script, the debugger
entry point is line 5 (which inreality is line 75) as follows:

Stack dump during die enabled outside of evals.

Loading DB routines from perl5db.pl patch level 0.94
Emacs support available.

Enter h or `h h' for help.

Unquoted string "null" may clash with future reserved word at junk.perl
line 70.
Useless use of a constant in void context.
main::(junk.perl:5):
5: #print "Loaded list\n";
DB<1> w
2: }
3: }
4: close(LIN); # we are done we have our list array.
5==> #print "Loaded list\n";
6:
7: open(INFILE, $datainputfile) or die "Can not open input
$datainputfile";
8: open(OUTFILE, "> " . $dataoutputfile) or die "Can not open
output $dataoutputfile";
9:
10: # read in real data and put in array!
11:
DB<1>

How can I get the debugger to start at the first executable line and
accurately reflect the source code
line numbers?


Here is the source code:

#!/usr/bin/perl

# variables

$sortlistfile = "";
$datainputfile = "";
$dataoutputfile = "";
$CMD = "";
$hit99 = 0; # boolean to trigger email with 99 notice

$NOTIFY = `cat /opt/apps/empower/cpi/control/CPI.notify`;
chomp($NOTIFY);
print $NOTIFY;

# take in file names as command line arguments. First the mask list,
# then the data input, then the data output.


chomp($ARGV[0]);
if ($ARGV[0] eq "-c") { exit; }

if (!($ARGV[2]))
{
print "Execute with: 'cpisort.perl masklist datainput dataoutput
[prog_to_run]'\n";
exit;
} else {
$sortlistfile = $ARGV[0];
$datainputfile = $ARGV[1];
chomp($ARGV[2]);
$dataoutputfile = $ARGV[2];
chomp($ARGV[3]);
$CMD = $ARGV[3];
}

@LIST = ""; # array holding list of sort patterns in sort order!
@DATA = ""; # array holding data from real input file. Index is
integer!
@MASKHITS = ""; #array holding relationship between masks
# in @LIST and lines in @DATA. @LIST index is index,
# while data is index from @DATA
@CARDLINE = ""; # will eventually contain list of lines split from
# @MASKHITS data to be printed as a group.

$TRUE = 1;
$opline = "";
$opmask = "";
$card_line_ctr = 0;
$file_line_ctr = 0;
$file_max = 0;
$list_line_ctr = 0;
$list_max = 0;
$knownmask = 0;
$ldelim = "~";

open(LIN, $sortlistfile) or die "Can not open $sortlistfile";

# read in list

while ($sline = <LIN>)
{
chomp($sline);
if ($sline)
{
if (!(substr($sline,0,1) =~ /^\#/))
{
$list_line_ctr++;
$list_max++;
$LIST[$list_line_ctr] = $sline;
#print "list " . $list_line_ctr . " " . $LIST[$list_line_ctr] .
"\n";
} else {
null; # is a comment
}
}
}
close(LIN); # we are done we have our list array.
#print "Loaded list\n";

open(INFILE, $datainputfile) or die "Can not open input
$datainputfile";
open(OUTFILE, "> " . $dataoutputfile) or die "Can not open output
$dataoutputfile";

# read in real data and put in array!

while ($fline = <INFILE>)
{
chomp($fline);
if ($fline)
{
$file_line_ctr++;
$file_max++;
$DATA[$file_line_ctr] = $fline;
}
}

# we don't need the INFILE any more we have it in an array
close(INFILE);

#print "Loaded \@DATA array\n";

# Now. Loop through @DATA line by line. Extract the bytes from
# positions 1, 2, 3, 14, 15, 18, 24, 64, 69, 80. Compare the resulting
string
# with ALL the masks in @LIST. If a match is found, use the @LIST index

# number as the index value into @MASKHITS, and take the index from
@DATA,
# the $file_line_ctr, and append it to the existing data value for
@MASKHITS.
# E.g., $MASKHITS[$list_line_ctr] = $MASKHITS[$list_line_ctr] .
# . $file_line_ctr . "~";
#

$file_line_ctr = 1; # must start at 1 or first element will look like
NULL
while ($file_line_ctr <= $file_max)
{
$opline = $DATA[$file_line_ctr];
#print "line " . $opline ."\n";
$opmask = substr($opline,0,3)
. substr($opline,8,1)
. substr($opline,13,3)
. substr($opline,17,1)
. substr($opline,23,1)
. substr($opline,63,1)
. substr($opline,68,1)
. substr($opline,79,1);

$lnum = substr($opline,89,13);

#print "linemask " . $file_line_ctr . " " . $opmask . "\n";

$knownmask = 0;

for ($list_line_ctr = 1; $list_line_ctr <= $list_max;
$list_line_ctr++)
{
#print "compare " . $opmask . "-" . $list_line_ctr . "-" .
$LIST[$list_line_ctr] . "\n";
if ($opmask =~ /$LIST[$list_line_ctr]/)
{
# Our real line mask matches!
$MASKHITS[$list_line_ctr] = $MASKHITS[$list_line_ctr]
. $file_line_ctr . $ldelim;
#print "matched " . $list_line_ctr . "-" .
$MASKHITS[$list_line_ctr] . "\n";
$knownmask = 1;
last;
}
}
# check to make sure we found a matching mask. If not, put the line
in a
# '99' category to be printed last.
if (!$knownmask)
{
$MASKHITS[99] = $MASKHITS[99] . $file_line_ctr . $ldelim;
print "99hit " . $opmask . " for loan " . $lnum . "\n";
$hit99 = 1;
}

$file_line_ctr++;
# remember that @MASKHITS may have entries that are NULL. If, for
example
# there are no trasn cards of type 20 (say "^0311...1") in today's
feed!
}

#print "Loaded \@MASKHITS array\n";
#print "MASKHITS AFTER LOAD " . $MASKHITS[0] . "**" . $MASKHITS[1] .
"\n";

# Now @MASKHITS is loaded. Simply go through each line of it by its
# index (you can use $list_line_ctr since this represents the same
value)
# and then find the LINES in $DATA that correspond to the string of
lines now
# stored as the data to @MASKHITS, eg. "2449010212345". Note the
presence
# of $ldelim at end of line. Should make split easy, but must use
split() into
# array as don't know how many lines there are matching any given @LIST
mask.
#

for ($list_line_ctr = 1; $list_line_ctr <= 99; $list_line_ctr++)
{
#print "MASKHITS " . $MASKHITS[$list_line_ctr] . "\n";
if ($MASKHITS[$list_line_ctr])
{
#We want to make sure this data at this position in $MASKHITS
# is not null!. @CARDLINE must never have null lines!
@CARDLINE = ""; # reinitialize this array

(@CARDLINE) = split(/$ldelim/,$MASKHITS[$list_line_ctr]);
#print "cardline " . $list_line_ctr . " " . $CARDLINE[0] .
$CARDLINE[1] . "\n";

# @CARDLINE should now be an array of line numbers in @DATA that
contain
# the cards we want from this particular line of @MASKHITS...

$TRUE = 1;
$card_line_ctr = 0;
while ($TRUE)
{
#print "cardline inside " . $CARDLINE[$card_line_ctr] . "\n";
if ($CARDLINE[$card_line_ctr])
{
# test for data, don't print otherwise cause we're at end
print OUTFILE $DATA[$CARDLINE[$card_line_ctr]] . "\n";
#print "cardline to output " .
$DATA[$CARDLINE[$card_line_ctr]] . "\n";
$card_line_ctr++;
}else{
# end of card, we can break from this while
$TRUE = 0;
}
}
}
}

# we should be done, so close output and do any reporting for test
# purposes, etc.

close(OUTFILE);
open(EMAIL, "| mailx -s'CPI sort report ' $NOTIFY");
print EMAIL "CPI file sorted\n";
if ($hit99) { print EMAIL "There were UNSORTABLE transactions!\n"; }
else
{ print EMAIL "There were no unsortable transactions.\n"; }
close(EMAIL);
if ($CMD) { exec $CMD; }

exit;


TIA

Luke
 
J

J. Gleixner

Unquoted string "null" may clash with future reserved word at junk.perl
line 70.
Useless use of a constant in void context.
How can I get the debugger to start at the first executable line and
accurately reflect the source code
line numbers?
} else {
null; # is a comment

Fix the syntax error and you'll be able to debug your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top