Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Implementation of Readline

by shyam123 (Initiate)
on Jun 13, 2013 at 09:27 UTC ( [id://1038711]=perlquestion: print w/replies, xml ) Need Help??

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

Hello monks,
I am trying to read from the serial device.I have tied with file handler and i access through it's file handler functions.My buffer size is 512 and i try to read only 40 bytes.And then display the 40 bytes line by line.I knew the existence of readline function which does the same,but i don't want to use that.The bytes i read are,
hi\nhow are
u\nhello iam fine\n
\nthe world\n is ve
ry beautiful\n
And i write "wow" string on to the serial device once i read the string "hello".After sending the data i read other two lines
. In short, both TX and RX are taking place on serial port and i need to read 40(or whatever is available) number of bytes.My output should be as below
hi
how are u
wow
hello i am fine
the world is very beautiful
I was trying split function,but i am not getting the appropriate output when the new line character comes in the next line.Can anyone throw some light on this.It would also be fine if anyone can jus share the snippets
thanks

Replies are listed 'Best First'.
Re: Implementation of Readline
by BrowserUk (Patriarch) on Jun 13, 2013 at 10:17 UTC

    I've read your description through 3 times, but it is still not clear to me what your problem is, or how we can help you.

    There is nothing wrong with the words you've posted, they are very clear, but they do not allow me to begin to guess what your code looks like. But then, why should I need to guess?

    Maybe if you posted your current code and demonstrated what output it is giving you now, we might be able to see how to modify it to produce the output you told us you want.


    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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 04:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found