in reply to How to use a regex to parse html form tags
That depends on the size of your file. If it's large, you might want to use the while() loop.
And even when I do get the simple Whey replaced with Popcorn - it only does the first instance, basically, I am guessing, because there is no iterative code in this script.
The iterative code you're looking for is a /g on the end of your s///.
However, that answer isn't going to solve your problems. If you want to eat non-mushy cereal, you need to put your dentures in. Use perl's dentures at the top of your code:
use strict; use warnings;
Finally, your eventual replacement pattern, /<form[.*]?*\/form>/ is flawed, and will not do what you appear to think it will do. The square brackets, [], indicate a character class, so what you're matching is <form, followed by either a literal . or a literal *, or nothing, followed by /form>.
The regex you are looking for(*) is m{<form.*?</form>}. Note the use of an alternative delimiter so the / doesn't need to be escaped.
(*) You are not looking for a regex, which are insufficient for parsing gobs of HTML/XML. The regex given above already has problems. :)
Cheers,
|
|---|