http://www.perlmonks.org?node_id=1038711

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