Why doesn't my regular expression work with Perl's Switch module? -


I wanted to use a switch statement. I ran into difficulties quickly It seems that I was inauspicious I decided to use the switch.

I wonder why this does not work, what do you do? It seems that there is a problem with Regular Expression / GC flag.

  Switch Usage; While (status ($ file) & lt; length ($ file)} {switch ($ file) {case (/ \ g \ s * object \ s + (\ w +) \ s * \: \ s * (\ W +) / gc) {}} Last if ($ oldpos == pos ($ file)); $ Oldpos = pos ($ file); }  

It was suggested that something like the matter (m! \ G \ s object \ s + (\ w +) \ s : \ s * (\ W +)! GC will work it is not.

Switch.pm is implemented with source filter, which can cause strange bugs to track down To make it very difficult I do not recommend using the switch in the output code due to its uncertainty. Switch.pm document that it may have trouble parsing the regex with the modifier.

If you are using Perl 5.10, you can use the new built-in syntax instead.

  Use the 'switch' feature; Given ($ file) {when (/ \ g \ s * object \ s + (\ w +) \ s * \: \ s * (\ w +) / gc) {...}}  

If you are using pre-5.10, then the best thing is to use a if / else structure


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -