#!/usr/bin/perl -w use strict; use warnings; use Carp; if(open(FILE, "text.txt")) { print "Opened text.txt!\n"; print "Reading file...\n"; my @array = ; close FILE; print "File read!\n"; print "Current text in file:\n"; print "**************\n"; foreach my $lines (@array) { print "$lines\n"; } print "**************\n"; print "Edit file?Y/N\n"; print "If answer is no,\n"; print "then the program will\n"; print "be closed.\n"; my $input = ; if($input =~ m/y/i) { print "Reopening file for\n"; print "editing...\n"; if(open(EDIT, ">text.txt")) { print "File sucessfuly opened\n"; print "for editing!\n"; if() { print "File has data.\n"; print "Overwrite? Y/N\n"; print "If answer is no,\n"; print "program will be closed.\n"; my $moreInput = ; if($moreInput =~ m/y/i) { print "Are you sure?\n"; my $evenMoreInput = ; } elsif($moreInput =~ m/y/i) { print "OK, then!\n"; print "Closing program...\n"; exit 0; } } } else { confess "Something went wrong! $!"; } } elsif($input =~ m/n/i) { print "OK, then!\n"; print "Closing program...\n"; exit 0; } else { print "That is not a valid\n"; print "answer. Type your\n"; print "answer again.\n"; $input = ; next SOMETHING; } } else { confess "Something went wrong! $!"; }