sub CreateServer { my($PORT) = 10066; my($ret); $server = IO::Socket::INET->new( Proto => 'tcp', LocalPort => $PORT, Listen => SOMAXCONN, Reuse => 1); die "can't setup server" unless $server; $client = $server->accept(); $client->autoflush(1); return $ret; } Can i use the below two lines of code for getting the fd before the return statement $ret = fileno $client; return $ret; And is it valid?.