Solved

Pattern search and conversion on octal dump files

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
use google analytics code in perl script 2 90
.properties file to call function/method 9 63
batch script for automated email 12 132
perl syntax 3 29
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…

679 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