Solved

display text

Posted on 2000-02-22
6
168 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
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.

 

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

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…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

914 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

17 Experts available now in Live!

Get 1:1 Help Now