Re: [SLE] How can I debug a PERL program ?

pelibali wrote:
Hi,
After commenting out more, than half of your program, it got confirmed, that your $erg variable is always empty. Our programming styles are slightly different, but you could solve your problem like this:
my($dummy, $erg, $MT, $ZA, $rest) = split( /\s+/, $line, 5);
So I added a first variable, which will be always empty, and increased the number of fields produced to 5. Now everything should work.
More elegant solution would be to put the pieces of the line into an array and simply skip it's element nr 0. Other similarly good solution would be to send your line through a s/// regexp to get rid of the leading space(s):
while (<INFILE>) ... $line = ($_ =~ s/^\s+//);
Best regards, Pelibali
Ps. Bug here: # Open output file open( OUTFILE, "> " . $outfile ) || die "ERROR: Can't open $infile: $!\n";
It works but I had to replace : <>$line = ($_ =~ s/^\s+//); with $line =~ s/^\s+//; because the assignment operator "=" coupled with the substitution operator, returns the characters being substituted so I was getting all lines made up of a whitespace only. Finally, in this simplest version, the Number of MT=18 records found by my PERL program coincides with the number found by just a bash shell command. ... which makes me feel confident that it does work. Thanks to your precious help I've learnt something about PERL. Thank you to you all. maura
participants (1)
-
Maura Edelweiss Monville