Keep It Simple, Stupid | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
My team was debating the idea of writing a large file using pipe characters to delimit the fields, and I pointed out that our data includes pipe characters. So the tilde was suggested, but I found some of those too. So the obvious question arises, can I find a printable ASCII character that never appears in our big file? I'd like to do this with just a single pass through the file. For locating a pipe character, all I had to say was
Update: Should have mentioned that I'm going to run any executable solutions against a 2 GB file. So efficiency may be an issue. Later: Thanks for the insights! I applaud almut's choice of an indicator array @seen, updated with $seen[ord $chr]++, which should be more efficient than the hash version $seen{$chr}++. I think I will try kennethk's solution using \Q, both as written and then with the indicator array, as soon as my daughters are in bed and I can connect to my server again. (Just a minute, sweetie, Daddy will be right with you ...) It's true the indicator array doesn't offer a builtin keys function to list the seen items, but a grep should do just fine. In reply to Find what characters never appear by Narveson
|
|