monoxide has asked for the wisdom of the Perl Monks concerning the following question:
This seems to work perfectly, BUT. Is there an easier/better way of doing this? Failing that, does anyone have any ideas on how to detect whether $BSD_STYLE should be set or not? I was thinking maybe running stty with some parameters and checking the output for some sort of signatures, but this seems to me to be a "bad" solution.#!/usr/bin/perl $BSD_STYLE = 1; if ($BSD_STYLE) { system "stty cbreak </dev/tty >/dev/tty 2>&1"; } else { system "stty", '-icanon', 'eol', "\001"; } my $in = ''; while (($key = getc(STDIN)) ne "\n") { $in .= $key; print "\x08 \x08"; } if ($BSD_STYLE) { system "stty -cbreak </dev/tty >/dev/tty 2>&1"; } else { system "stty", 'icanon', 'eol', '^@'; # ASCII null } print "$in\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Ghosted input
by naikonta (Curate) on Jun 15, 2007 at 04:14 UTC | |
by monoxide (Beadle) on Jun 15, 2007 at 04:34 UTC | |
|
Re: Ghosted input
by tirwhan (Abbot) on Jun 15, 2007 at 08:04 UTC |