tags:

views:

63

answers:

1

I used Term::ShellUI and almost every thing is working as expected but the issue is when I pressed Ctrl-C I want to print:

Please use ctrl+d to exit the shell

For that I handle the signal but the message print only after I pressed the new line How to resolve this?

+2  A: 

You can do the same without using the IO::Handle library, by setting the $| variable to 1 before printing.

$SIG{INT} = sub {
   $| = 1;
   print "Please use ctrl+d to exit the shell";
}
darkturo