How to create a Unix Domain socket?
<p>I am trying to learn how to use sockets to communicate between processes on the same machine. I started with this simple test program taken from Perl Cookbook:</p>

<pre><code>use feature qw(say);
use strict;
use warnings;
use IO::Socket;

my $socket_file = 'mysocket';
if ( -e $socket_file ) {
    unlink $socket_file or die "Could not delete socket file '$socket_file': $!";
}
my $sock = IO::Socket::UNIX-&gt;new(
    LocalAddr =&gt; $socket_file,
    Type      =&gt; SOCK_STREAM,
    Listen    =&gt; 5, # listen to max 5 connections
) or die "Could not create socket: '$@'";

say "Created socket successfully..";
sleep 1;
close $sock;
say "Closed socket..";

exit;
</code></pre>

<p>The output is:</p>

<pre><code>Could not create socket: '' at ./test.pl line 10.
</code></pre>

<p>So the question is: Why does <code>IO::Socket::UNIX-&gt;new()</code> fail, and why does it not set <code>$@</code> when it fails?</p>