in reply to direct data to a socket
The $_[0] is the socket that is passed from the accept into the sub. The filename is looked up and if it is executable, a pipe is created with it, otherwise it is opened directly. In either case the contents of the resulting IO::All object are fed into the $_[0] socket. Very similar to the simplistic use of '<' in:
$contents < io 'file.txt';
So this oneline web server can send the contents of simple files, or the generated output from executables.
Update: The reason you couldn't find anything in perldoc is because this is an operator that has been overridden to act in this way by IO::All which is where the simple example above comes from. Thus, you can only use the '<' operator this way with IO:All objects.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: direct data to a socket
by demoralizer (Beadle) on Oct 22, 2014 at 08:54 UTC | |
by Corion (Patriarch) on Oct 22, 2014 at 08:57 UTC | |
by jonadab (Parson) on Oct 22, 2014 at 10:43 UTC | |
by choroba (Cardinal) on Oct 22, 2014 at 12:03 UTC | |
by jonadab (Parson) on Oct 23, 2014 at 00:38 UTC | |
by demoralizer (Beadle) on Oct 22, 2014 at 09:05 UTC | |
by Loops (Curate) on Oct 22, 2014 at 08:58 UTC |