This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use feature (feature_bundle); | |
use v5.36; | |
BEGIN {print feature_bundle(0); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -l http://localhost:3000/bar.html | |
HASH(0x55bcb62743c8) | |
cat myapp.pl | |
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
get '/bar' => sub { | |
my $data = {one => {foo => 1}, two => 24}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
davido@davido-desktop:~/scripts$ cat mytest.pl | |
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use 5.020_000; | |
use Text::CSV; | |
use feature qw(state); | |
use Data::Dumper; | |
use Test::More; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doswald@pro-doswald-ll3:~/repos/testml$ make test | |
git branch --track testml-tml origin/testml-tml 2>/dev/null || true | |
git worktree add -f testml-tml testml-tml | |
Preparing worktree (checking out 'testml-tml') | |
HEAD is now at cc3197c Adjust test for new CLI option | |
npm install --save-dev diff ingy-prelude lodash | |
npm WARN saveError ENOENT: no such file or directory, open '/home/doswald/package.json' | |
npm WARN enoent ENOENT: no such file or directory, open '/home/doswald/package.json' | |
npm WARN doswald No description | |
npm WARN doswald No repository field. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub tv_mark { | |
my $t0 = [gettimeofday]; | |
state $cum = 0; | |
if ($_[0]) { | |
my $c = $cum; | |
$cum = 0; | |
return $c; | |
} | |
else { | |
return sub { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Benchmark qw(:hireswallclock); | |
# The point: No controller logic in add1, mult2, power. | |
# But we will run add1 and mult2 in parallel, and then wait for them to finish before taking the power. | |
sub add1 { my $a = shift; sleep 2; return $a+1; } | |
sub mult2 { my $b = shift; sleep 2; return $b*2; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
BEGIN { | |
foreach my $method (qw(foo bar)) { | |
no strict 'refs'; | |
*{__PACKAGE__ . '::' . $method} = sub {return $method}; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Normally when a quantified subpattern does not allow the rest of the | |
overall pattern to match, Perl will backtrack. However, this behaviour is | |
sometimes undesirable. Thus Perl provides the "possessive" quantifier form | |
as well. | |
*+ Match 0 or more times and give nothing back | |
++ Match 1 or more times and give nothing back | |
?+ Match 0 or 1 time and give nothing back | |
{n}+ Match exactly n times and give nothing back (redundant) | |
{n,}+ Match at least n times and give nothing back |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chomp( | |
my @words = do{ | |
open my $word_ifh, '<', '/file/path/wordthree.txt' or die $!; | |
<$word_ifh>; | |
} | |
); | |
my $alternation = join '|', @words; | |
my $regex = qr/($alternation)/; | |
my @hits; |
NewerOlder