faqts : Computers : Programming : Languages : Perl : Common Problems : Splitting Strings

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 6 people (100%) answered Yes
Recently 5 of 5 people (100%) answered Yes

Entry

I have a 4KB piece of text data. How can I detect/remove binary data from this?

Jan 26th, 2001 06:43
Robert Bogomip, George Roberts,


$numdeleted = $data =~ tr / -~\012//cd
This kills anything that's not in the printable ascii range from space
to tilde (the "\012" leaves newlines in as well). $numdeleted is left
with the number of characters removed.