Pattern search and conversion on octal dump files
Posted on 2001-06-21
I have a file I am getting from a main frame that I display on the web using CGI.
However, on certain occassions I find that the displayed data is not wrapping correctly.
I am using <PRE> tags ... and in most cases all is well.
Using vi or vf will display the data the way it should be. You don't see anything out of the ordinary.
But when looking at the data in octal ..
> od -co <filename>
I see that the wrapping problem is everytime it has a null value ( \0) or 000 ( octal )
Is there a way I can open the file in a way that I can search and remove the NULL values?
Maybe I need to do a character array and check each character as it is read in and if it finds the \0 value, replace it with a space or something.
How would I write this code?
This is what I have now:
open (IN, "$INFILE");
open (OUT, ">$OUTFILE");
@lines = <IN>;
print OUT @lines;
Would I need to open the file in a binary mode and read it in that way then convert the NULL value ... Any ideas or suggestions would be appreciated.