use strict; print "do you want to continue(y\/n):"; chomp (my $answer = <>); my $name = "foo.txt"; if ($answer=~/y/i){ my $first = "bar.txt"; Edit($first); } elsif ($answer =~/n/i){ exit } ################################### sub Edit{ my $nod = shift; ## so here i enterd the file i want to open open (NOD, "<", $nod)|| die "$!"; open (NAMES, "<", $name) || die "$!"; open (OUT, ">", "out.txt") || die "$!"; ...some proces... close NOD; close NAMES; close OUT; print "do you want to continue(y\/n):"; chomp (my $change = <>); if ($change =~/y/i){ print "what you wish to change:"; chomp (my $cho = <>); if ($cho){ open (SEC, "<", $nod)|| die "$!"; open (NEW, ">", "simon.txt") || die "$!"; ... do something... print NEW "$_"; } close NEW; open (ADD, ">>", "simon.txt")|| die "$!"; print ADD "\| -- -- --\|\n"; close ADD; } elsif ($change =~/n/i){ exit } print "one more time(y\/n):"; chomp(my $a =<>); if ($a =~/y/i){ my $rr = "simon.txt"; #### and here if i choose to continue, want to redo the proces but this time with this new file Edit($rr); } elsif ($a =~/n/i){ last } }