Galdor has asked for the wisdom of the Perl Monks concerning the following question:

I have been using the python one-liner:

python -m SimpleHTTPServer 8080

to pull files from various remote machines for ages and it works really well, quick and easy.

It occurs to me that as *Puerveyor of Perl* (aka JAPH) I should be using a Perl equivalent. Go-on tickle my fancy...

Anyone know how to do this in Perl?

Replies are listed 'Best First'.
Re: perl one-liner to serve httpd current directory
by Your Mother (Archbishop) on Aug 22, 2018 at 19:12 UTC

    A couple more. Plack::App::Directory is what I usually use–

    plackup -MPlack::App::Directory -e 'Plack::App::Directory->new({root = +> q{.}})->to_app'

    This (not necessarily recommended but good to know about) IO::All recipe does executables like CGIs too–

    perl -MIO::All -e 'io(":8080")->fork->accept->(sub { $_[0] < io(-x $1 +? "./$1 |" : $1) if /^GET \/(.*) / })'

    Update: because that verbosity is off-putting, I'd like to add that I use the first as this alias.

    moo@cow[36]~>which www www: aliased to plackup -p 5000 -MPlack::App::Directory -e 'Plack::App +::Directory->new({root => q{.}})->to_app'
Re: perl one-liner to serve httpd current directory
by Corion (Patriarch) on Aug 22, 2018 at 19:03 UTC
Re: perl one-liner to serve httpd current directory
by haukex (Archbishop) on Aug 22, 2018 at 22:12 UTC
Re: perl one-liner to serve httpd current directory
by Anonymous Monk on Aug 24, 2018 at 17:57 UTC
    perl one-liner to serve httpd current directory

    App::SimpleHTTPServer - Serve up a directory via http simply and easily:

    $ # To serve the current directory via http on port 8000, simply do: $ perl -MApp::SimpleHTTPServer $ # or use the serve_dir script: $ serve_dir
Re: perl one-liner to serve httpd current directory
by Anonymous Monk on Aug 24, 2018 at 17:49 UTC
    SimpleHTTPServer is a core python module. Perl does not provide a core HTTP server module. Perl actually removed the core HTTP request processing modules in 2014. Instead of bloating the core, Perl prefers to stay lean by relying on modules installed from the CPAN. As you can see from the other replies there are many Perl HTTP server modules.
      Perl actually removed the core HTTP request processing modules in 2014.

      Which modules are that? CGI.pm was removed in Perl 5.022, but CGI is not HTTP (and to be extra nitpicky, 5.022 wasn't released until 2015).