Maybe using IO::Socket will make your life easier, since it doesn't require getting down and dirty like you have done with sysread. It's an IO::Handle, which makes reading and writing from it a lot simpler, and besides, making sockets has never been easier.

As an additional note, you probably want to use strict. You have declared $buffer and then you use $buf, and $numBytes is undeclared, at least in your example.

Further, your last regular expression (regex) is specified as /<*>/. You may not realize that "*" is special, meaning here "zero or more of the previous character", so this will match any of the following: >,<>,<<>,<<<>, etc. It will not, however, match <*> since this is not just angle brackets. For that, you need to use /<\*>/.

If you meant to specify that there is something inside angle brackets, then what you need is /<[^>]*>/ or /<([^>]*)>/ where the second version puts the contents of the brackets in $1.

In reply to Re: Need Help On the Socket Connection. by tadman
in thread Need Help On the Socket Connection. by Draff

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.