Every time the code picks up a new line in the file it prints a horizontal margin as follows (exact output from the file)
<br> ______________________________________________________________________ +_____________________________________________________________________ +____________________________<br> Farhan<br> Khalid<br> This <br> ______________________________________________________________________ +_____________________________________________________________________ +_________________________<br> makes <br> ______________________________________________________________________ +_____________________________________________________________________ +_________________________<br> any <br> ______________________________________________________________________ +_____________________________________________________________________ +_________________________<br> difference <br> ______________________________________________________________________ +_____________________________________________________________________ +_________________________<br> to <br> ______________________________________________________________________ +_____________________________________________________________________ +_________________________<br> the script <br> ______________________________________________________________________ +_____________________________________________________________________ +_________________________<br> ______________________________________________________________________ +_____________________________________________________________________ +_________________________<br> 18:31:42, Wed Aug 6, 2008<br>

But what i am looking for is the output to be generated as follows

______________________________________________________________________ +_____________________________________________________________________ +_________________________<br> Farhan<br> Khalid<br> This <br> makes <br> any <br> difference<br> to <br> the script<br> 18:31:42, Wed Aug 6, 2008<br> ______________________________________________________________________ +_____________________________________________________________________ +______________________________________

the code below please advise what changes need to be made
#!/usr/bin/perl -w use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); my $query= new CGI; my $filename= "testfile.txt"; my $value; my $fname; my $lname; my $textarea; my $delimiter_used="|"; my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); my @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun); my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfW +eek, $dayOfYear, $daylightSavings) = localtime(); my $year = 1900 + $yearOffset; my $theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $months[$m +onth] $dayOfMonth, $year"; sub Writing_to_file { my @input_to_file=@_; open (DAT, ">>$filename") || die ("no file exists"); print DAT join($delimiter_used, @input_to_file), "\n"; close(DAT); } sub display_on_browser { open (DAT, $filename) || die ("no file exists"); my @data_in_the_file=<DAT>; close(DAT); print "Content-type:text/html\n\n"; print "<html><head><title>Guestbook</title></head><body> +"; for my $line (@data_in_the_file) { my @fields = split(/\Q|\E/gm, $line); for my $field (@fields) { print "<br>$field"; } print "<br>___________________________________________ +_____________________________________________________________________ +____________________________________________________"; } print "<a href=http://guestbook.ds5403.dedicated.turbodns.co.uk/in +dex.html><h1>Back to Guestbook</a>"; print "</body></html>"; } $fname=$query->param('name'); $lname=$query->param('name1'); $textarea=$query->param('comments'); if ($fname eq "") { print "Content-type:text/html\n\n"; print "<html><head><title>Guestbook</title></head><body>"; print "<b>You have missed out your first name</b>"; print "<a href=http://guestbook.ds5403.dedicated.turbodns.co.u +k/index.html><h1>Back to Guestbook</a>"; print "</body></html>"; } elsif($lname eq "") { print "Content-type:text/html\n\n"; print "<html><head><title>Guestbook</title></head><body>"; print "<b>You have missed out your last name</b>"; print "<a href=http://guestbook.ds5403.dedicated.turbodns.co.u +k/index.html><h1>Back to Guestbook</a>"; print "</body></html>";} elsif($textarea eq "") { print "Content-type:text/html\n\n"; print "<html><head><title>Guestbook</title></head><body>"; print "<b>You have missed out your comments</b>"; print "<a href=http://guestbook.ds5403.dedicated.turbodns.co.u +k/index.html><h1>Back to Guestbook</a>"; print "</body></html>";} else { Writing_to_file($fname,$lname,$textarea,$theTime); display_on_browser(); }

20080807 Janitored by Corion: Put output into code tags so it doesn't wide the page


In reply to Problem with a new line by jinnks

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.