in reply to Re: stty functionality in Perl
in thread stty functionality in Perl

With POSIX, I could do this:
#!/usr/bin/perl use strict; use POSIX qw(:termios_h); my $term = POSIX::Termios->new; $term->getattr(fileno(STDIN)); print join(" - ", IGNCR, ECHO, ~ECHO, ECHOK, ICANON, $term->getlflag() + )." \n"; print ($term->getlflag() | (ECHO | ECHOK |ICANON) ); print "\n"; print ($term->getlflag() & ~(ECHO | ECHOK |ICANON) ); print "\n"; print ($term->getlflag() | (ECHO | ECHOK |ICANON) ); print "\n";
Is there a simpler way than this to set and unset raw/crlf or echo on/off mode?

Replies are listed 'Best First'.
Re^3: stty functionality in Perl
by ambrus (Abbot) on Apr 08, 2005 at 20:11 UTC

    Yes, I call stty from the perl code like

    system "stty", qw"-echo -echonl -echoke -echoe -isig" and die "error during stty"; ... system "stty", "sane" and warn "cannot reset stty settings";
    in a script I've written. Replace the flags with whatever you want. If you don't want to install addittional modules, I doubt there's a simpler way then these two.
Re^3: stty functionality in Perl
by derby (Abbot) on Apr 08, 2005 at 20:12 UTC

    Well ... yes. Term::ReadKey but your boss is in the way there if it's not on your system or system but your in your own way not wanting to use system.

    -derby
      We have been using the system function, but just as with installing extra modules, my boss does not want us to use system().
        Could your boss explain to us (and you) why he doesn't want you to install additional modules from reliable source, well tested and widely spread? And why he forces you to invent the wheel yourself, thus inevitably making all the mistakes others already have made and have solved since?,

        It's like not trusting Ferrari for building good race cars and trying to build one yourself... Don't expect me to take a ride!

        Paul