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.