|go ahead... be a heretic|
Re: Big problem in pattern matchingby kennethk (Monsignor)
|on Jun 04, 2013 at 14:38 UTC||Need Help??|
There's a lot going on in your code; both as a debugging exercise and a convenience to those who would like to help you, you should try to simplify your posts down to the most compact code that replicates your issue. It has been my experience that bugs often identify themselves when I try to isolate them. See How do I post a question effectively?.
Your variable $string contains the escaped contents of the variable $test, which is never initialized in your code. I'm thinking this is an error in your post, not if your original code. Please make sure that posted code replicates what you are actually running, so we can debug the right thing. In this case, both strict and warnings would have flagged the issue. See Use strict warnings and diagnostics or die.
If I'm reading your spec right, your line featuring my $content =~ ... is supposed to grab the entire 'word' following your match. However, because you've used the binding operator (=~), you are actually running your regular expression against an uninitialized value (again, an issue caught by warnings). What you probably meant to do was
This runs the previous expression extended to include all trailing lower-case alphabetic characters, extracts the match, and uses list assignment to store the match (List value constructors). Easier would be to run the code as
since capturing stores the value in $1 (Variables related to regular expressions). Note that I've removed the g modifier and escaped slashes because I don't think that's what you meant.
Let me know if I've missed the spec here.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.