You are using join wrong. Join's args are (first) the new delimiter, and (second) the list of strings being joined. I think that you probably don't even want join at all, you probably (based on your existing code) simply want concatenation as follows:

if( $tmp > 0 ) { $sip_response .= "$line\n"; }

Also notice the use of '>' instead of 'gt'. 'gt' is for strings, and '>' is for numbers. Your use of 'gt' works for you, but only by virtue of the fact that Perl considers any non-empty, non-zero string to be "true".

Additional thought:
An easier way to do the whole thing is probably something like this:

my $sip_response = $response; # Make a copy of the response. if( $sip_response =~ s{^[^\n]+}[200 SIP/2.0 OK] ) { print $sip_response; } else { die "Didn't understand the response: $response\n"; }

...just a thought...


Dave


In reply to Re: splitting and joining a network message by davido
in thread splitting and joining a network message by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.