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 / db.pl
Created August 28, 2014 08:49
Simple database query simulated with CSV files and hashes
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
my %data;
open my $fh2, '<', 'file2.txt' or die $!;
### Keybase proof
I hereby claim:
* I am davorg on github.
* I am davorg (https://keybase.io/davorg) on keybase.
* I have a public key whose fingerprint is 4D8C A086 7A90 F3F0 AD97 F554 2A0F E00B D8E3 5D11
To claim this, I am signing this object:
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
my %letter;
@letter{'a' .. 'z'} = reverse 'a' .. 'z';
open my $word_fh, '<', '/usr/share/dict/words' or die $!;
@davorg
davorg / vote.pl
Created September 25, 2011 18:03
This appears to be all you need to polljack a Daily Mail poll.
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use LWP::UserAgent;
$|++;
@davorg
davorg / mysql-import
Created March 9, 2012 16:43
Create MySQL Table Definition and Insert Statements From CSV
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Text::ParseWords;
use List::Util 'max';
my $file = shift || die "Need a csv file to process\n";
@davorg
davorg / po-trace
Created August 14, 2012 14:31
Command line program to check recorded post via the UK Post Office
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use LWP::Simple;
my $url = 'http://www.postoffice.co.uk/track-trace?trackNumber=XX' .
'&page_type=rml-tracking-details';
@davorg
davorg / dispatch.pl
Created November 12, 2012 09:16
Simple dispatch table example
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
# Define allowed operations
my %operation = (
'>' => sub { $_[0] > $_[1] },
'<' => sub { $_[0] < $_[1] },
@davorg
davorg / copy_file.pl
Created November 29, 2012 09:58
Copy file contents to new file named using timestamp
#!/usr/bin/perl
use strict;
use warnings;
use Time::Piece;
my $src_file = 'ABC.txt';
my $t = localtime;
open my $in_fh, '<', $src_file
@davorg
davorg / gist:4321043ca6e926c5eb84
Created December 10, 2015 08:38
Overriding CORE::GLOBAL::open
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
BEGIN {
no strict 'refs';
use Symbol ();
use Devel::Peek;
@davorg
davorg / prime.pl
Created April 20, 2013 16:53
Simple prime checker
#!/usr/bin/perl
use warnings;
use strict;
while(<DATA>) {
chomp;
my $flag = 1;
foreach my $i (2 .. sqrt($_)) {