Solved

Pattern search and conversion on octal dump files

Posted on 2001-06-21
2
217 Views
Last Modified: 2012-06-27
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:
=================================================
    print "<pre>";
    open (IN, "$INFILE");
    open (OUT, ">$OUTFILE");
    @lines = <IN>;
    print @lines;
    print OUT @lines;
    print "</pre>";

==================================================

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.
Thank you
0
Comment
Question by:tgbekele
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 100 total points
ID: 6214937
s/\0/ / for @lines;
0
 

Author Comment

by:tgbekele
ID: 6215115
ozo,

I was going around in circles trying a hard way of doing it ... thank you very much!
This worked great!

T
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question