my $string = join( "\n", qw(howdy partner goodbye Friend saynora adios Amigo) ); open(MY_FILE, '>my_file.txt'); print MY_FILE $string; close(MY_FILE); &edit_file('my_file.txt'); sub edit_file { my $my_file = shift; my $editor = $ENV{'editor'}; system('vim', $my_file); my $validate = &validate_file($my_file); print "File is ok\n" if $validate; } sub validate_file { my $my_file = shift; open( MY_FILE, $my_file ) or die "Unable to open file\n"; while( ) { chomp( $_ ); unless( $_ =~ /^[a-z]/ ) { close( MY_FILE ); print "Error at line $.\n"; print "$_ does not begin with a lower case letter\n"; print "Hit return to continue: "; ; &edit_file( $my_file ); } } close( MY_FILE ); return 1; }