Solved

display text

Posted on 2000-02-22
6
161 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

13 Experts available now in Live!

Get 1:1 Help Now