M
msargent100
Perl newbie question -
I am having a problem finding the end of a string. I determined there
are nulls at the end but I do not know how many nor how to get rid of
them. I did a reverse on the variable and then looking at substr($x, 0,
1), I get a null returned.
What happened -
I am reading from a binary file that has fixed length fields but the
contents of the field may be variable length strings. To get the data I
need I pull the contents of the field using the substr function with an
offset and length of the field. So the text field is always
64-characters long, but the values in the field will vary considerably.
So my question is: How can I find the end of the characters and assign
only the valid characters to the variable and drop the nulls?
I'm trying to use the data extracted from the binary file to
access/insert into a database. SQL does not like nulls at the end of
the values being inserted.
Thanks,
Mike
I am having a problem finding the end of a string. I determined there
are nulls at the end but I do not know how many nor how to get rid of
them. I did a reverse on the variable and then looking at substr($x, 0,
1), I get a null returned.
What happened -
I am reading from a binary file that has fixed length fields but the
contents of the field may be variable length strings. To get the data I
need I pull the contents of the field using the substr function with an
offset and length of the field. So the text field is always
64-characters long, but the values in the field will vary considerably.
So my question is: How can I find the end of the characters and assign
only the valid characters to the variable and drop the nulls?
I'm trying to use the data extracted from the binary file to
access/insert into a database. SQL does not like nulls at the end of
the values being inserted.
Thanks,
Mike