Skip to content

Instantly share code, notes, and snippets.

View davorg's full-sized avatar
💭
Perlin'

Dave Cross davorg

💭
Perlin'
View GitHub Profile
@davorg
davorg / gist:da13a9603bc3b0a1521ab70dbe04865f
Created April 21, 2022 14:37
Bash function to get Perl module versions
function cpanver {
for mod in "$@"
do
perl -M$mod -E"say qq[$mod - \$$mod::VERSION]"
done
}
@davorg
davorg / count_log
Created June 24, 2021 10:39
Simple program to count the type of log events in a Log4Perl file
#!/usr/bin/perl
use strict;
use warnings;
my $logs;
while (<>) {
my ($date, $time, $type) = split;
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use DBI;
my $dbh = DBI->connect(
"DBI:mysql:database=test",
@davorg
davorg / cpanbugtracker
Created December 6, 2020 12:36
Simple program to find CPAN distributions by an author that do not include information about a bugtracker
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use MetaCPAN::Client;
my $author_name = shift
or die "Usage: $0 CPAN_AUTHOR_ID\n";
use strict;
use warnings;
use Test::More;
use Plack::Test;
use Plack::Util;
use HTTP::Request::Common;
my $app = Plack::Util::load_psgi './app.psgi';
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
my $target = 92;
my @prices = (35, 46, 19, 7, 41, 27);
# If we have command-line arguments
@davorg
davorg / challenge01
Last active July 29, 2019 14:42
Perl Weekly Challenge #19 / Task #1
#!/usr/bin/perl
#
# Perl Weekly Challenge #19 / Task #1
#
# Write a script to display months from the year 1900 to 2019 where
# you find 5 weekends i.e. 5 Friday, 5 Saturday and 5 Sunday.
use strict;
use warnings;
use feature 'say';
@davorg
davorg / wall
Created March 17, 2019 15:03
Wall stuff for T
#!/usr/bin/perl
use strict;
use warnings;
use SVG;
my $PICWIDTH = 22;
my $svg = SVG->new(width => 184, height => 200);
@davorg
davorg / blood.cgi
Last active March 5, 2019 08:28
Simple CGI program to answer question on Reddit
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw(param header);
my $title = 'Blood Test';
my $content = param('bloodtype') ? get_results() : get_form();
print header;
@davorg
davorg / nme-scraper
Last active December 13, 2018 16:24
Scraping the NME's top 100 albums of 2018
#!/usr/bin/perl -CS
use strict;
use warnings;
use utf8;
use feature 'say';
use Web::Query;
my $page = 'https://www.nme.com/blogs/nme-blogs/' .