#!c:\perl\bin\perl -w use strict; my $logfile="C:/Documents and Settings/Andrew Robert/My Documents/Perl/test_file.txt"; my $yes_no; my $add_line; sub yesno { $yes_no=uc($yes_no); if (($yes_no ne "Y") || ($yes_no ne "YES")) { return 1; } } open(TESTFILE, ">>$logfile")||die("unable to open file\n"); while (1) { print "Enter line of text to add : "; $add_line=; print TESTFILE $add_line; print "Add another line? (Yes/No) :"; if (yesno(chomp($yes_no=))==1) { close (TESTFILE); print "\nWrite operations complete - File closed\n"; exit 1; } }