I've always admired Python's way of serving local files by simply doing:
$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
And I've been wondering if there's a way to achieve the same in Perl without requiring lots of dependencies from CPAN. This morning I just came out with this:
$ perl -Mojo -E 'a->static->paths(["."]);a->start' daemon
Server available at http://127.0.0.1:3000
It shows the file content, though it doesn't show the directory listing.
Is there any simpler way?
By Yary
on
February 10, 2016 1:29 PM
I think of text, grammars that parse the text, and the syntax trees (data) generated by a parser as a triangle. Most of the time in computerland, people doing something with this triangle are interested in converting a text into a tree using a parser.
Every once in a while I need to write a parser. My first serious parser was in the late 90's, for a radio station that needed each week to convert a large plain-text weekly email to tables of venues and shows. For that, I used a version of Bison (yacc) that allowed me to write actions in Perl.
These days, I'm excited to get my hands dirty in Perl6 grammars. Writing a correct parser is never easy, so a clean, well-thought-out "featureful" parser language means less effort spent on fighting the tool, more on attacking the problem.
By JT Smith
on
February 9, 2016 11:00 AM
Tonight we’re meeting at The Bodgery where Timm will show us all the crazy cool stuff he’s been doing with Perl and Quadcopters.
[From my blog.]
We're happy to announce that the 9th annual Perl QA Hackathon (QAH) will be held in Rugby in the United Kingdom. The event will run from Thursday 21st April to Sunday 24th April.
The QAH is a face-to-face gathering of the lead developers who work on the Perl toolchain that all Perl programmers rely on and build upon. The first QAH was held in Norway, in 2008, and so far it's always been in Europe. The QAH provides dedicated time over 4 days to work on the critical systems and tools, with all the right people in the same place.
Hey everyone,
Following is the p5p (Perl 5 Porters) mailing list summary for the past week. Enjoy!
By Dean
on
February 8, 2016 12:45 PM
Broadbean have offered to host us next month, thanks be to Peter H for setting the wheels in motion once again.
What: Sydney PM
Date: Tuesday, 16th Feb 2016
Time: 6-9:30pm
Where: Broadbean, Suite 8.03, 9 Hunter Street, Sydney
Lloyd speaking on Perl 6, John will speak about Perl and its natural-language features.
People, please join us via:
Facebook
Meetup.com
B::C has now better support for copy-on-write (COW) strings with about 6%
memory savings for 5.20 and 5.22.
The perl5.18 implementation for COW strings is totally broken as it
uses the COW REFCNT field within the string. You cannot ever come to a
true successful copy-on-write COW scheme. You cannot put the string
into the .rodata segment as with static const char* pv = "foo"; it
needs to be outlined as static char* pv = "foo\000\001";. The byte
behind the NUL delimiter is used as REFCNT byte, which prohibits its
use in multi-threading or embedded scenarios. In cperl I'm was working
on moving this counter to an extra field, but the 2 authors made it
impossible to write it in a maintainable way. I could easily seperate
the refcnt flag but I couldn't make it COW yet.
This is a module I wrote a while back, but I never announced. I am pretty happy with how this came out, so here's the announcement. Some JAPHs might be disappointed to learn that one feature of Perl 5 that did not make it to 6 is globbing. That is, doing something like this:
for my $file (glob "src/core/*.pm") { say $file }
With just Perl 6, you need to do something like this instead:
for "src/core".IO.dir(:test(/ .* ".pm" $/)) -> $file { say ~$file }
That's not too terrible, but I still miss the simplicity of globs. In that case, I can use IO::Glob:
use IO::Glob;
for glob("src/core/*.pm") -> $file { say ~$file }
That does the same thing as the Perl 5 code, more or less.
But, that's not all. I always wished that globs could be used for pattern matching. Sometimes, just matching a string against a glob is handy, but Perl 5's globs are narrow minded. IO::Glob is not: