"be consistent" | |
PerlMonks |
Re^3: Please fix my writing styleby juster (Friar) |
on Nov 22, 2008 at 19:48 UTC ( [id://725351]=note: print w/replies, xml ) | Need Help?? |
You may want to use dragonchild's solution because it is easier to understand. You will need to read up on "do" to understand it better. do is not a loop, using next will only exit the block. Let me try to avoid using do. "Slurping" a file means reading all its data into a string. There alot of ways to do that, search for file slurping on Super Search to understand it better. Once you have the file data the regexp is easier to understand:
The problem with the code I supplied is \s matches whitespace, including a newline. If you replace \s with just a space character, it will skip the bad lines. The important thing to learn is how the global match /<regexp>/g can return a list of results, or the number of matches depending on what you assign it to. See perlretut (ie Extracting matches), perlre, search here, etc.
In Section
Seekers of Perl Wisdom
|
|