Skip to content

Instantly share code, notes, and snippets.

@ggl
ggl / htpasswd.pl
Last active October 18, 2021 21:51
htpasswd in perl, no need to install apache tools
#!/usr/bin/env perl
#
# htpasswd.pl
#
# Copyright (c) 2013, Gelu Lupas <gelu@devnull.ro>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
@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 / poi_sqlite.pl
Last active September 10, 2016 08:02
Create a POI SQLite database from a Garmin CSV
#!/usr/bin/env perl
use strict;
use warnings;
use DBI;
use Data::Dumper;
use Geohash;
use Text::CSV;
@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;