This is my first posting so forgive my ignorance.
I am using substrings in a screipt and wondered if there was a better
perlish way to do it. I am taking data from a mainframe system and
reformatting it but the substring seems to be quite slow, like visual
basic, the original.
Any pointers on a better method would be much appreciated.
Here is some of the code:
__SNIP__
my @fields = unpack($template, $_);
# add zoned decimals - overpunch requires translation
for $i (8,9,10,12) {
if (unpack(c1,(substr($fields[$i],-1))) > 57)
{
substr($fields[$i],-1) =~ tr/}JKLMNOPQR/0123456789/;
$fields[$i] = '-' . substr($fields[$i],1,12);
}
# add decimal, point
$fields[$i] = substr($fields[$i],0,11) . '.' .
substr($fields[$i],-2);
}
# find bad character and replace with a space or whatever
my @testbad = unpack(c65,$fields[7]);
print LOG "Unpacked format for array: \n";
for $i (0..64) { print LOG $testbad[$i]; }
print LOG "\n";
for $i (0..64) {
if ($testbad[$i] == 13) { $testbad[$i] = 40; }
}
__SNIP__
Many Thanks,
Mark Bedish
Surrey,UK