in reply to Re: control-d out of loop?
in thread control-d out of loop?

<body>

Update: There is a way to do this.

However, it is a VI trick.

To input a control-d, you press control-v then a control-d.
This will put a control-d char in variable that you can use to trap for a control-d being pressed.

This code does not have the special char. It is just an example. If you want to try it replace 
the ^D with the sequence I described...

$control_d = '^D';

while (chomp($char = <STDIN>)) {
        print "control_d $control_d char = $char\n";
        if ($char eq '^D) { # control D
            print "gotcha\n";
            last;
        }
}

 

</body>