#!/usr/bin/perl -w $|++; use strict; use IO::Socket; use IO::Select; my $response = IO::Socket::INET->new(Proto=>"udp",LocalPort=>5000) or die "Can't make UDP server: $@"; my $sel = new IO::Select( $response ); my ($datagram,$flags); binmode($response); while(my @ready = $sel->can_read) #Make sure socket has something to give us { $datagram = ''; $flags = ''; $response->recv($datagram,1500,$flags); my $length = length($datagram); print "Length : $length\n"; if($datagram =~ /^(\C\C\C\C)(.*)$/s) { #Do some stuff } else { #Didn't match for some reason print "Did not match!\n"; } }