B
Bob Mariotti
Here's one for the perl internals guru's:
We have a module that is used by many programs in our suite.
Currently it works and has been working just fine for several years.
What it does is take a string that is passed to it and sends it out a
tty port to a remote host then it enters into a read loop
contatenating all returned records until it receives one beginning
with "0999". Here is a sample snippet (NOT ACTUAL CODE)
If the very most cases this works just absolutely fine as the records
coming back are either one or a few or at most a dozen or two.
However, we've added a request that will return upwards of 1000+
records of 115 bytes each. The time to execute is becoming
unacceptable and my thought is that the reallocation of the scalar
variable $DATA is costing too much in time and resource.
Is there any good way to preallocate that scalar to approx 1000 x 115
before entering the loop so the re-allocation, data content move, and
destruction of the old scalar doesn't have to happen????
Also, can anyone recommend a more efficient method for obtaining and
passing these/this data back to the calling routine???
Thanks all.
Bob Mariotti
"perl is great!"
We have a module that is used by many programs in our suite.
Currently it works and has been working just fine for several years.
What it does is take a string that is passed to it and sends it out a
tty port to a remote host then it enters into a read loop
contatenating all returned records until it receives one beginning
with "0999". Here is a sample snippet (NOT ACTUAL CODE)
$DATA="";
open(XXX,"+>/dev/ttyxxxx") or die $!;
# Send Request to host
print XXX "$Message\015" or die $!;
# Get Response from host
while (<XXX>) {
# Exit if Last Record Signal
if (m/^0999/) { last; }
# Contruct Host Response String
$DATA.=$_;
}
return $DATA;
If the very most cases this works just absolutely fine as the records
coming back are either one or a few or at most a dozen or two.
However, we've added a request that will return upwards of 1000+
records of 115 bytes each. The time to execute is becoming
unacceptable and my thought is that the reallocation of the scalar
variable $DATA is costing too much in time and resource.
Is there any good way to preallocate that scalar to approx 1000 x 115
before entering the loop so the re-allocation, data content move, and
destruction of the old scalar doesn't have to happen????
Also, can anyone recommend a more efficient method for obtaining and
passing these/this data back to the calling routine???
Thanks all.
Bob Mariotti
"perl is great!"