Forgive me if I am incorrect, but if you added more code that needed executing after the "your input was" printout, your script there would still be forced to quit after 10 seconds, as you do not reset the alarm in your code. Here's how I'd throw it together:
#!/usr/bin/perl -w
$| = 1;
use strict;
my $answer = 'n';
eval {
local $SIG{ALRM} = sub { die("timed out\n"); };
print "Invoke script? (y/n) ";
alarm(10);
chomp( $answer = <STDIN> );
alarm(0); # reset the alarm so it won't go off later
};
# user entered text other than 'y' or else the 10s is up
if ($@ eq "timed out\n" or lc($answer) ne 'y') {
die("No positive answer. Aborting execution.\n");
}
# some other error blew within the eval - best to die()
elsif ($@) {
die($@);
}
# we got the 'y' answer, so now we continue:
print "Executing remainder of script.\n";