Just another Perl shrine | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I tried to output the chomped text to a txt file. When I open that text file in a text editor it shows weird overlapping text (like some sort of graphical problem). [from this; emphasis added] afoken has already covered the cross-system line-end mismatch and chomp problems pretty well. Here's a further example:
The other thing that occurs to me is that your original file has "invisible" whitespace characters other than the \r \n line-enders: spaces, tabs, etc. If these exist at the end of a line, it will cause a problem. Try something like (untested): In general, processing a file of a few hundred megabytes entirely held in memory should not be a big problem, depending on what you're doing, and you're basic approach (insofar as I can understand what it is) looks ok to me. And, of course, the golden rule: Know Your Data! Update: BTW: my $content = do { local $/; <$filehandle>; }; is the "file slurp" idiom; it does a raw read of the entire file to a string. Give a man a fish: <%-{-{-{-< In reply to Re: Regular expressions across multiple lines
by AnomalousMonk
|
|