Skip to content

Instantly share code, notes, and snippets.

@ggl
ggl / cleaner.pl
Created March 20, 2014 11:53
PHP malware cleaner
#!/usr/bin/env perl
use strict;
use warnings;
use File::Copy;
use Path::Iterator::Rule;
unless ($ARGV[0]) {
print "usage: $0 <directory>\n";
@ggl
ggl / json-time.pl
Created May 20, 2014 17:24
Timing JSON modules
#!/usr/bin/env perl
use strict;
use warnings;
use Try::Tiny;
use Benchmark qw(cmpthese);
use JSON::XS ();
use Cpanel::JSON::XS ();
use JSON::Tiny;
@ggl
ggl / viewcsv.pl
Last active December 18, 2015 18:19
Display a CSV file to STDOUT using Data::Dumper or YAML::Tiny
#!/usr/bin/env perl
#
# Display a CSV file to STDOUT using Data::Dumper or YAML::Tiny
use strict;
use warnings;
use Getopt::Std;
use Text::CSV;
use Data::Dumper;
@ggl
ggl / echo.pl
Last active December 19, 2015 18:59
Echo server example using AnyEvent
#!/usr/bin/env perl
use strict;
use warnings;
use AnyEvent;
use AnyEvent::Socket;
use AnyEvent::Handle;
my ($host, $port) = parse_hostport('127.0.0.1:8000');
@ggl
ggl / benchmark.pl
Last active December 26, 2015 14:39
Moo vs. Mo vs. Class::Tiny vs. Mojo::Base
#!/usr/bin/env perl
package Boo;
use Moo;
has blah => ( is => 'ro' );
sub bla {
my ($oh, @ah) = @_;
@ggl
ggl / miclasstiny.pl
Last active December 26, 2015 21:59
Class::Tiny multiple inheritance?
package Blah;
use strict;
use warnings;
use Class::Tiny qw(blah);
sub bla {
my ($oh, @ah) = @_;
return join(' ', ucfirst($oh->blah), @ah);
@ggl
ggl / array_match.pl
Last active December 28, 2015 18:49
Four ways to match two arays
#!/usr/bin/env perl
# four ways to match two arays
use strict;
use warnings;
use match::smart qw(match);
use Test::Deep;
use Benchmark qw(cmpthese);
@ggl
ggl / date_comp.pl
Created December 4, 2013 13:15
Time::Piece and Class::Date benchmarked
#!/usr/bin/env perl
#
# Time::Piece and Class::Date benchmarked
#
use strict;
use warnings;
use Benchmark qw(cmpthese);
use Time::Piece;
@ggl
ggl / histogram.pl
Last active September 10, 2016 07:36
Generate a histogram from a list of numbers
#!/usr/bin/end perl
use strict;
use warnings;
use Data::Dumper;
my $hist = sub {
my $input = shift;
if ($input and $input =~ /^\d+$/) {
@ggl
ggl / sereal-child.pl
Last active September 10, 2016 07:36
Start a child process and feed it Sereal encoded data
#!/usr/bin/env perl
use strict;
use warnings;
use Child;
use Data::Dumper;
use Sereal::Encoder;
use Sereal::Decoder;