in reply to Coding CTRL-D

try this: #!/usr/bin/perl #other stuff print pack("c", 04"); # c is for signed character value, and 04 is control-d, aka, EndOfTransmission.