Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^4: Printing a String (TOO stupid?)

by Laurent_R (Monsignor)
on Jun 18, 2014 at 18:46 UTC ( #1090330=note: print w/ replies, xml ) Need Help??

in reply to Re^3: Printing a String (TOO stupid?)
in thread Printing a String (TOO stupid?)

That's wrong in this specific case. Here, you have a Windows file with "\r\n" line ends. Under Unix, the chomp command will remove only the "\n" part, but not the "\r". Using chomp a second time will not remove the "\r" under Unix. So the printing goes back to line start and the three !!! overwrite the beginning of the line.

The best solution here is to remove the "\r":

chomp $line; $line =~ s/\r//g;
$line =~ s/[\r\n]//g;

Comment on Re^4: Printing a String (TOO stupid?)
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2015-11-29 15:30 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (751 votes), past polls