#!/usr/bin/perl # vi:ts=4 sw=4 et: use strict; use warnings; print "continue [y/N]? "; chomp ( my $answer = ); # any other answer than 'y' or 'Y' results in an termination of the program if ( $answer !~ m/[Yy]/ ) { exit 0; } # process first foo( 'foo.txt' ); sub foo { my $file = shift; print "work with '$file'\n"; print "continue [y/N]? "; chomp( $answer = ); if ( $answer !~ m/[yY]/ ) { exit 0; } print "change what? "; chomp( my $to_change = ); if ( defined $to_change ) { print "wanted to change: $to_change\n"; } print "again [Y/n]? "; chomp( $answer = ); if ( $answer !~ m/[Yy]/ ) { exit 0; } print "running again: \n"; # process second foo( 'bar.txt' ); }