#!/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! $!"; } #### if($input =~ m/y/i) { #do something } elsif($input =~ m/n/i) { #do something else } else { #do something different } #### import java.util.Scanner; public class Stuff { public static void main(String[] args) { Scanner somethingScan = new Scanner(System.in); int lotsOStuff = somethingScan.nextInt(); MoreStuff(lotsOStuff); } public static void MoreStuff(int something) { System.out.println(something); } } #### my $input = #### Scanner newScan = new Scanner(System.in); String input = newScan.nextLine(); #### youngs-mac-mini:Documents fenimore$ perl SomeStuff.pl Opened text.txt! Reading file... File read! Current text in file: ************** ************** Edit file?Y/N If answer is no, then the program will be closed. y Reopening file for editing... File sucessfuly opened for editing! Filehandle EDIT opened only for output at SomeStuff.pl line 43. youngs-mac-mini:Documents fenimore$