You have an error with precedence in your regular expression. The alternation (|) doesn't know where you want it to stop. See YAPE::Regex::Explain if you want a module that explains regular expressions to you.
Your regular expression currently matches like
(?-imsx:^REGISTER|INVITE|BYE\s\w\.\w\sSIP/2.0)
matches as follows:
NODE EXPLANATION
----------------------------------------------------------------------
^ the beginning of the string
----------------------------------------------------------------------
REGISTER 'REGISTER'
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
INVITE 'INVITE'
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
BYE 'BYE'
----------------------------------------------------------------------
\s whitespace (\n, \r, \t, \f, and " ")
----------------------------------------------------------------------
\w word characters (a-z, A-Z, 0-9, _)
----------------------------------------------------------------------
\. '.'
----------------------------------------------------------------------
\w word characters (a-z, A-Z, 0-9, _)
----------------------------------------------------------------------
\s whitespace (\n, \r, \t, \f, and " ")
----------------------------------------------------------------------
SIP/2 'SIP/2'
----------------------------------------------------------------------
. any character except \n
----------------------------------------------------------------------
0 '0'
----------------------------------------------------------------------
Maybe you want the Net::SIP module instead of writing your own module?
As an aside, putting your code between <code>...</code> tags makes the code render and download nicely for those who want to try it.
Update: YAPE::Regex::Explain installed and I updated the explanation
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.