We call perl scripts from within a IBM tool. The way we do this is make a call to JAVA runtime process and run a perl command on the server, the java process returns the output/error of the PERL script. In our testing we found at times the java process just hangs. Looks like the PERL script doesnt throw any output or error and just quits??
code is below
=cut
use strict;
use warnings;
my $infilename = $ARGV[0];
my $outfilename = $ARGV[1];
my $header = $ARGV[2];
my $readoffset = $ARGV[3];
my $readreccnt = $ARGV[4];
my $inreccnt = 0;
my $outreccnt = 0;
print "StartTime:";
print scalar localtime(time);
open my $INFILE, '<', $infilename;
seek $INFILE, $readoffset, 0;
open my $OUTFILE, '>>', $outfilename;
if ($artheader ne 'NOHDR'){
$artheader =~ tr/'^'/' '/;
print $OUTFILE "$header\n";
$outreccnt++;
}
READLOOP: while (<$INFILE>){
$inreccnt++;
if ($inreccnt > $readreccnt){
last READLOOP;
}
s/^HHH\.S.*//s;
s/^EEE\.S.*//s;
s/^0000\S{4}\s{2}//;
print $OUTFILE $_;
$outreccnt++;
}
close $INFILE;
close $OUTFILE;
print ",EndTime:";
print scalar localtime(time);
print ",\n";
print "InFileName:";
print $infilename;
print ",ReadOffset:";
print $readoffset;
print ",ReadRecordCnt:";
print $readreccnt;
print ",OutFileName:";
print $outfilename;
print ",OutRecordCnt:";
print $outreccnt;
print ",\n";
print "HeaderLen:";
print (length $artheader);
print ",HeaderData:";
print $header;
print ",\n";
earlier i had use autodie but then took it out.
I am new to PERL, is there a case where a PERL script can just quit and not throw any. Should i use "use autodie"?
-
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.