Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: getc vs readline

by dave_the_m (Monsignor)
on Nov 30, 2019 at 19:57 UTC ( [id://11109490]=note: print w/replies, xml ) Need Help??


in reply to getc vs readline

getc() uses the same input buffer as readline. getc() won't normally return after a single character like 'X' is entered; it waits until a whole line has been entered (including \n), then returns the first character of it. readline() sees the remainder of the line still in the buffer and returns immediately. For example, if the user types "abc\n", then at the point the user presses carriage-return, getc() returns "a" and readline() immediately follows on returning "bc\n".

If you truly want to get the next character even if the user hasn't pressed return yet, then look into something like Term::ReadKey.

Dave.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11109490]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 12:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found