17 private links
an overview of Type::Tiny
Perl 5 with modern defaults
Useful One-Line Scripts for Perl Jul 11 2018 | version 1.11 |
---|
Compiled by Peteris Krumins (peter@catonmat.net, @pkrumins on Twitter)
http://www.catonmat.net -- good coders code, great reuse
Latest version of this file is always at:
http://www.catonmat.net/download/perl1line.txt
This file is also available in other languages:
Chinese: https://github.com/vinian/perl1line.txt
Please email me peter@catonmat.net if you wish to translate it.
Perl One-Liners on Github:
https://github.com/pkrumins/perl1line.txt
You can send me pull requests over GitHub! I accept bug fixes,
new one-liners, translations and everything else related.
I have also written "Perl One-Liners Explained" ebook that's based on
this file. It explains all the one-liners here. Get it at:
http://www.catonmat.net/blog/perl-book/
No Starch Press has published "Perl One-Liners" as a real book too:
http://nostarch.com/perloneliners
Slides of Tim Bunce's talk on Devel::NYTProf and optimizing perl code at YAPC::NA in June 2014. It covers use of NYTProf and outlines a multi-phase approach to optimizing your perl code.
:dromedary_camel: List of resources about Perl.
:dromedary_camel: List of resources about Perl.
My favorite "failed" project: I was with a company that decided to rewrite a Perl project in C++ because Perl was too slow.
glot.io lets you run and share snippets.
Snippets can be saved as either public or secret. Public snippets will show up in /snippets and will be found by search engines. Secret snippets can only be accessed by those who know the url.
Code is executed inside a temporary container without a network connection. Execution time is limited to 15 seconds and the output can not exceed 100KiB. Memory is limited to 500MB.
Ace is used as the code editor. Make sure to check out the leftmost and rightmost tabs, where you can select language version, set a custom run command and change the editor keybindings.
Are you missing your favorite library or language? Issues and pull requests are gladly accepted here.
BUILD
is called after the constructor, which makes it handy to verify state but not necessarily useful to format incoming arguments.
BUILDARGS
would let you modify incoming arguments before the constructor is called, which makes it a better fit for this case. Your attribute is read-only, so this could work.
But... if you're hungry for static typing, why would you stop after promising "this is a string"? If you create a subtype for ISO8601 strings, you can promise "this is a string and it has X format". Even better, you're doing that in a way that's immediately and trivially portable to other attributes.
I rather doubt the regex below will work for you, but I hope it will get the point across:
#define the type
subtype 'iso8601',
as 'Str',
where { /\d{4}-\d{2}-\d{2}/ },
message { "Not a valid ISO8601 string ($_)" };
#provide a coercion
coerce 'iso8601',
from 'Str',
via { _format_as_iso8601 $_ };
#tell moose to coerce the value
has startdate => (is => 'ro', isa => 'iso8601', required => 1, coerce => 1);
Last Christmas, the inimitable Matt Trout (mst) created an opinionated tour of CPAN where he recommended modules for some common problems. I think its brilliant, useful, and entertaining and I’ve decided to compile a high level overview all on one page in order to create a quick reference.
I’ve tried to distill his wisdom and wit down to a few words. But I recommend clicking the section headers and following the links to Matt’s original posts to see his actual real opinions in their full complexity. This single page can’t replace 16 great posts and he usually includes advice on the best way to use the module. You won’t want to miss that.