[Nh-pm] removing embedded hex from a text file?

Mark Polhamus meplists at earthlink.net
Thu Oct 31 05:12:38 CST 2002


chr() converts a number to the corresponding character, and ord() converts it 
back.  As in s/$c//go.  (I bet there is a way to do that without the temporary 
var $c, but I can't find it right now).  So:

     perl -p -e '$c = chr(0xA0); s/$c//go'

(not tested)


-- Mark Polhamus

pll at lanminds.com wrote:
> Hi all,
> 
> I have what's *supposed* to be a csv file dump of a spread sheet.  
> However, when I print it out using perl, I see the chars <A0> in the 
> file all over the place.  When I look at it in hexl-mode in emacs, 
> sure enough, those same characters are 0xa0.
> 
> How can I easily replace those in a quick perl one-liner?  I was 
> originally trying to remove exess spaces, which is what lead me to 
> discover these characters.
> 
> I'm sure this is an obvious thing, but my brain isn't working well 
> right now.  I tried:
> 
> 	perl -ane '$_ =~ s/0xA0//; print "$_\n";' file.csv
> 
> But since 0xA0 is a character, not a string, this won't work.
> 
> Thanks,





More information about the Nh-pm mailing list