We don't bite newbies here... much | |
PerlMonks |
Re: Removing non-printing (hex codes) from text filesby oiskuu (Hermit) |
on Feb 06, 2014 at 22:54 UTC ( [id://1073777]=note: print w/replies, xml ) | Need Help?? |
Do you know what encoding these files are using? There are tools to convert from one encoding to another. If you really need to filter unprintable characters, line by line, then does this, but also converts to unix line endings... tr/// will be faster, however. Characters \177-\377 aren't ASCII printable, you may want to filter those, too. There's no need to chomp line ends, only to add them back later.
Even better is to specify the good characters, remove anything other. Consider using fixed-length input (avoid arbitrary big line buffers). Finally, you probably want raw binmode to avoid problems with ^Z and so on. See open.
In Section
Seekers of Perl Wisdom
|
|