#!/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="|"; 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=; close(DAT); my $data_to_read; print "Content-type:text/html\n\n"; print"Guestbook"; foreach $data_to_read(@data_in_the_file) { my @delimiter_to_remove=$data_to_read; @delimiter_to_remove=~s/\$delimiter_used/\n/g; print "
@delimiter_to_remove\n
"; } print "

Back to guestbook"; print ""; } $fname=$query->param('name'); $lname=$query->param('name1'); $textarea=$query->param('comments'); Writing_to_file($fname,$lname,$textarea); display_on_browser();