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; }
In reply to Re: Custom interrupt?
by pc88mxer
in thread Custom interrupt?
by azredwing
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |