All pastes #916692 Raw Edit

Stuff

public text v1 · immutable
#916692 ·published 2008-02-24 21:22 UTC
rendered paste body
#!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=<STDIN>;
  print TESTFILE $add_line;
  print "Add another line? (Yes/No) :";
  if (yesno(chomp($yes_no=<STDIN>))==1)
     {
      close (TESTFILE); 
      print "\nWrite operations complete - File closed\n";
      exit 1;
     } 
 }