Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: how to remove

by 7stud (Deacon)
on Jun 15, 2011 at 23:11 UTC ( #909876=note: print w/ replies, xml ) Need Help??


in reply to how to remove

You've opened a can of worms. You need to read up on "unicode". The bottom line is that you need to know the "encoding" of any data you read from a file. An "encoding" tells perl how many bytes each integer in your file occupies. Remember computers store characters as integers.

Here's an example. Suppose these bytes are in your file:

0000 0001 0000 1000

If you tell perl that your file is encoded in such a way that the first integer occupies 1 byte, then perl will read the following for the first integer:

0000 0001

which is equivalent to 1 in decimal. However, if you tell perl that your file is encoded in such a way that the first integer occupies 2 bytes, then perl will read the following for the first integer:

0000 0001 0000 1000

which is equivalent to 8 + 256 = 264 in decimal. So depending on what encoding you specify, perl will read in a different integer(and again remember that the integers are just codes for characters).

By the way, \015 is not the special character ^r (up arrow+r). \015 is the octal syntax for the decimal integer 13, which is the ascii code for a carriage return. The fact that you tried to remove them from a file is very suspect. Please explain why you were doing that.


Comment on Re: how to remove
Select or Download Code
Re^2: how to remove
by ZWcarp (Beadle) on Aug 07, 2013 at 20:10 UTC
    perl -i -pe 'tr/\015/\n/d' Quick fix for getting rid of Excel or other windows markup when reading in a unix or linux environment. this one just changes over the carriage returns as you said.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2014-08-29 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls