Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: How to convert a text file to a HTML file

by ghosh123 (Monk)
on Jan 25, 2013 at 12:43 UTC ( #1015337=note: print w/ replies, xml ) Need Help??


in reply to Re^2: How to convert a text file to a HTML file
in thread How to convert a text file to a HTML file

Hi

Thanks for your input. Now let me re-iterate my problem this way. Suppose I have simple a.txt(pasted below) file in my desktop. When I open that file on the browser by giving the unix path/windows path ...it comes in proper order and indentation.

But when I am reading this file in a string and inserting the string in a database column and later on using cgi perl printing it on the webpage , it gets messed up.

What magic is happening when I do print $htmldata in my cgi perl code so that it destroys the order and indentation of the text ?

name    phone

xyz    123

abc    890

But it is coming as :

name phone xyz 123 abc 890 Thanks


Comment on Re^3: How to convert a text file to a HTML file
Re^4: How to convert a text file to a HTML file
by marto (Bishop) on Jan 25, 2013 at 12:51 UTC

    You've posted no code, why make people guess what $htmldata is? You don't show us how you read this input, what processing is done on the input or how you display your output. If all you do is read the data into a variable and print it within a webpage it isn't going to display in the same manner it did within your text editor. You need to learn about HTML, and basic perl. Rather than have to reiterate your problem consider putting some thought into your posts, and asking a real question, How do I post a question effectively?.

Re^4: How to convert a text file to a HTML file
by ghosh123 (Monk) on Jan 25, 2013 at 13:04 UTC

    Hi

    Yes it is just a single line , so I did not put a code. But I have mentioned that I am fetching the concatenated string from the database and I assumed that people would understand $htmldata is holding that value fetched from database.

    I am using a fetchrow_hashref function to fetch the data .

    Thanks.

      First off, you replied to yourself, you've posted here many times, if you wish to reply to someone click the "reply" link within the post in question. Secondly you're still missing the point, you don't mention how you read the input data, how you process it (parse it from the format it's in into HTML) and how you display it. But I mentioned this already, among other things. If you continue to ignore what people say in response to your questions then you're wasting your time.

Re^4: How to convert a text file to a HTML file
by RichardK (Priest) on Jan 25, 2013 at 13:14 UTC

    html generally ignores white space, so if you want it displayed in a particular layout then you need to add some markup.

    Try wrapping your text in a pre tag i.e.  <pre>your text here</pre>

    BTW the browser knows how to display different file types, but if your app tells the browser it's sending html and then just sends plain text, it's not surprising that you don't get the results you expected.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015337]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2014-12-25 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls