jinnks has asked for the wisdom of the Perl Monks concerning the following question:
<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
the code below please advise what changes need to be made______________________________________________________________________ +_____________________________________________________________________ +_________________________<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> ______________________________________________________________________ +_____________________________________________________________________ +______________________________________
#!/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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Problem with a new line
by toolic (Bishop) on Aug 06, 2008 at 18:38 UTC | |
Re: Problem with a new line
by starX (Chaplain) on Aug 06, 2008 at 18:47 UTC | |
by jinnks (Novice) on Aug 06, 2008 at 19:32 UTC | |
by starX (Chaplain) on Aug 06, 2008 at 20:32 UTC | |
Re: Problem with a new line
by TGI (Parson) on Aug 07, 2008 at 01:21 UTC | |
by jinnks (Novice) on Aug 07, 2008 at 02:40 UTC | |
Re: Problem with a new line
by spivey49 (Monk) on Aug 06, 2008 at 18:25 UTC | |
Re: Problem with a new line
by Cristoforo (Curate) on Aug 06, 2008 at 19:53 UTC | |
by Cristoforo (Curate) on Aug 06, 2008 at 21:53 UTC | |
Re: Problem with a new line
by tptass (Sexton) on Aug 06, 2008 at 22:37 UTC |