Perl: the Markov chain saw | |
PerlMonks |
Replacing \n even when it shouldn't be :/by ultranerds (Hermit) |
on May 18, 2010 at 07:08 UTC ( [id://840456]=perlquestion: print w/replies, xml ) | Need Help?? |
ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
Got a bit of a weird one. I'm trying to write some code to "clean up" my HTML pages (so they are smaller and more SEO friendly) I've got this line: $html =~ s/\s{2,100}/ /sig; ...and: $html =~ s/\s+/ /sig; ..but that seems to replace the newlines (so the WHOLE page is all one one line) These are the other lines (but I've commented them out, just to check which line was causing the problem)
I'm at a real loss as to whats going on Can anyone suggest anything? Surely should be a simple case of /\s+/ / ? I've also done a little test script, and have exactly the same issue:
..and that outputs: TIA Andy
Back to
Seekers of Perl Wisdom
|
|