Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pattern search and conversion on octal dump files

Posted on 2001-06-21
2
Medium Priority
?
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
Six Sigma Control Plans

722 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