Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

ALTernative solutions?

by ExReg (Priest)
on Dec 19, 2011 at 16:32 UTC ( #944274=perlquestion: print w/replies, xml ) Need Help??

ExReg has asked for the wisdom of the Perl Monks concerning the following question:

I am wondering if there is any way to determine if just the ALT key has been pressed. The biggest problem I have is that I am restricted to a 5.005 machine without the ability to load CPAN answers to my problem. I can do it on the Windows side with Win32::Console, but the linux side does not have that. I do not have Term::ReadKey, just Term::Cap. I can use sysread or read to get the odd keys, such as function keys or arrow keys, but not just the ALT key. I believe this may not be possible with the perl that I have. Ideas?

Replies are listed 'Best First'.
Re: ALTernative solutions?
by BrowserUk (Patriarch) on Dec 19, 2011 at 16:55 UTC
    I am restricted to a 5.005 machine without the ability to load CPAN

    Why? Why would you suffer all the 1000s of problems that have been fixed in the last 13 years?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      That's what I ask myself all the time, but it will not change. What I have is all that I get.

        I commiserate.

        I'd love to know what (kind of) organisation would mandate such a thing. And their reasoning.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

Re: ALTernative solutions?
by pobocks (Chaplain) on Dec 20, 2011 at 04:27 UTC

    Can you use system()? If you can call out to the shell, you should be able to work something up with stty and/or setmetamode.

    I'm currently on OSX, and these don't function on my ssh terminal, so I can't work out an example for you, but googling on those two programs should get you started.

    for(split(" ","tsuJ rehtonA lreP rekcaH")){print reverse . " "}print "\b.\n";
      I can use system and have called out to the shell to be able to read the arrow and function keys. Still not the ALT key. I have not been able to find enough info on how to do it with stty or setmetamode. The mans (or is it men?) are a bit too terse. Google is not much better. Still searching.

        Have you considered looking inside Term::ReadKey or Term::Readline to see how they do it?

        While you're there, you might just as well c&p the appropriate bits of their tried and tested code into your application.

        Of course, once you've done that, why not just grab the whole package and stuff it into your project verbatim.

        But then, what is the difference between doing that and just installing the module and using it?


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://944274]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2022-10-07 22:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (30 votes). Check out past polls.

    Notices?