Bill Harpley wrote:
I must process the output of an SQL query using Perl.
I know the column position of the data in the output file, which means
that I am able to calculate the width of each field.
All of the data in the file is left-aligned to the field, except for one
column.
Basically, in the output of the SQ query, the right-aligned colum looks
like this:
NODE_UL
=============
146
281
985
So both the data and Field Title are right-aligned to the column.
I am using a function cal of the form:
$field_value=substr( $input_line , $field_start, $field_width ) ;
Where:
$input_line : line read from the source data file
$field_start : fixed value read from a table (array)
$field_width : calculated value of the field width, from the field
boundary definitions in the table
$field_value: value retruned by the function
However, for some strange reason, the Perl substr() function is unable
to read the right-most character of a right-aligned field. So in the
output data the above numbers would be 14, 28, 98.
I have extended the boundary column number in the field definition
table, so that substr() uses a bigger field width. But this has not
solved the problem. Extending the field boundary to the right has no
effect, even if I use a ridiculous value.
Does this sound like some sort of bug?? The substr() function has no
problem processing left-aligned fields and I have have said, increasing
the field width does not solve the problem either.
I am using Perl 5.8.4 on Solaris.
I found this in perl585delta.pod:
ยท Several obscure bugs involving manipulating Unicode strings
with "substr" have been fixed.
So perhaps you are dealing with Unicade strings?
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/