Solved

Pattern search and conversion on octal dump files

Posted on 2001-06-21
2
215 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now