Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

display text

Posted on 2000-02-22
6
Medium Priority
?
203 Views
Last Modified: 2010-03-05
i have a text file on my server but when i try to display it it can look funny

most lines are only half the width of the screen and then some lines only contain one word

example:
this is a test where i will show
what
i mean.

now this might be due to the fact that
the .txt files have a \n after certain lines.
would there be a way to display the file in html ignoring these \n's.....

thanks
0
Comment
Question by:paulwhelan
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:PC_User321
ID: 2545524
You can easily delete the lines when you read the text file, like this:-

@Lines = `cat myfile`;     # (Replace 'cat' with 'type' if on a PC)
chomp @Lines;

Now the array @Lines has the contents of myfile but with all new lines removed.  When displayed in HTML it will not have those short lines.
0
 

Author Comment

by:paulwhelan
ID: 2545558
thanks for the help
on efinal thing

now when my text is displayed i have
a scroll bar at the bottom and i have to scroll all the way over to the right to read the text

can the text be kept on the screen ( irealise that i may have to scroll down, i just dont want to scroll to the right)

is this something to do with html?

thanks
paul
0
 
LVL 5

Expert Comment

by:PC_User321
ID: 2545790
I would expect it to wrap automatically to fit the window.  I just did an experiment - I renamed a text file to x.html, and when viewed in a brouser it wrapped to fit the width of the window.  It was not necessary to remove the carriage returns.
0
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!

 

Author Comment

by:paulwhelan
ID: 2546241
i was using the html tags <pre> and </pre>

if i dont use the tags the text loses all paragraph infomration.

I want it to preserve everything except for the fact that i have to scroll to the right.

0
 
LVL 3

Accepted Solution

by:
monas earned 400 total points
ID: 2546813
ok, if you want text to be alligned by browser - you have to forget about <pre> - it should be html.

If you want to preserver paragraphs - then you should insert html's command for paragraph - <p>. In most cases paragraphs are separated by empty lines. - Therefore let's change all empty lines with <p>s. Code below:

open(F, "your.file");
@Lines = map {s/^\s*$/\<p\>/; $_} <F>;
close(F);

Now you can output @Lines, and say "it's HTML!"

Good Look!
0
 

Author Comment

by:paulwhelan
ID: 2546833
thats seems to have worked!
thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
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

886 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