in reply to Custom interrupt?

This is a hack, but you can probably make it work. When the user hits ESC, you can die. Then you can catch it and perform whatever cleanup that needs to be done:
sub enter_products { my @database = read_from_db(); eval { while (1) { ... $comment = my_prompt "Enter comment"; $descript = my_prompt "Enter description"; $sku = my_prompt "Enter sku"; $weight = my_prompt "Enter weight"; $color = my_prompt "Enter color"; ... $yn = my_prompt "Add another entry?", -yn; ... } }; unless ($@ =~ /\AESC PRESSED/) { die $@; # propagate non-ESC exceptions } write_to_db(...); } sub my_prompt { my $input = prompt @_, -escape if ($input eq "\e") { die "ESC PRESSED"; } return $input; }