http://www.perlmonks.org?node_id=822426

Kelly22 has asked for the wisdom of the Perl Monks concerning the following question:

I have been working on a a perl script for awhile and everything is going well other then I am constantly confused by how the regexs work.

It is my understanding that a line like string =~ s/"//; should replace all occurrences of " with nothing. However the strings it acts on usually have 2 ", and to eliminate both of them I have resorted to repeating the line.

Another series of regexs are not working as I expect them to either.

foreach (@content) { if ($content[$count] =~ /entertainment_headlines.gif/ or $content[ +$count] =~ /Chewy Headline Snacks/ or $content[$count] =~ /FEATURED INK/ or $content[$count] =~ / +StatCounter/ or $content[$count] =~ /NW Insider/ or $content[$count] =~ /twitterbadge22/){ splice(@content, $count, 1); } $count++; }
I believe this should elimiate array entries that contain these strings, but it doent seem two work msot of the time. It doesnt eliminate the array entry that ends with
</table> </div> <div class="moduletable"> <h3> FEATURED INK </h3> <table class="contentpaneopen">

or the one that contains

<!-- Start of StatCounter Code --> <br /><script type="text/javascript"> var sc_project=3028426; var sc_invisible=0; var sc_partition=32; var sc_security="0f2a9250"; </script> <script type="text/javascript" src="http://www.statcounter.com/counter +/counter_xhtml.js"></script><noscript><div class="statcounter"><a cla +ss="statcounter" href="http://www.statcounter.com/"><img class="statc +ounter" src="http://c33.statcounter.com/3028426/0/0f2a9250/0/" alt="f +ree html hit counter" /></a></div></noscript> <br /><!-- End of StatCounter Code -->

And while I am at it I also want to elimiate all newline characters from a string and assumed that $string =~ s/\n//; would do that but it doesnt seem to work at all.

Clearly I am not getting something about regexs. I have read up on them and its still not clear to me what I'm doing wrong. Any help or generally some negative reinforcement would be greatly appreciated.