Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

display text

Posted on 2000-02-22
6
Medium Priority
?
200 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
[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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

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…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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

719 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