Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Strings mangled on printing

by atcroft (Abbot)
on Jun 03, 2015 at 18:12 UTC ( [id://1128984]=note: print w/replies, xml ) Need Help??


in reply to Re: Strings mangled on printing
in thread Strings mangled on printing

$rt = $inp; chomp $rt; # insert at line 23 $rt =~ s/Remote Temp://;

chomp() would probably be more appropriate, since it removes (from the docs) "any trailing string that corresponds to the current value of $/ (also known as $INPUT_RECORD_SEPARATOR in the 'English' module)", and $/ can be set to the appropriate value if there is a difference in line endings/separators (such as "\n" vs. "\r" vs "\r\n" vs. ...).

Hope that helps.

Replies are listed 'Best First'.
Re^3: Strings mangled on printing
by roboticus (Chancellor) on Jun 03, 2015 at 22:47 UTC

    atcroft:

    Normally, I'd agree with you, but since the data is coming over a serial port, I wouldn't expect the line endings to be consistent with those used on whatever platform runs the code. So in this case, I'd prefer explicit removal of junk from the end.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-16 14:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found