Skip to content

Instantly share code, notes, and snippets.

View briandfoy's full-sized avatar

brian d foy briandfoy

View GitHub Profile
use 5.010;
use Data::Dumper;
my %hash;
while( my $line = <DATA> ) {
chomp $line;
given ( $line ) {
@briandfoy
briandfoy / gist:1342877
Created November 6, 2011 13:29
Perl regex escapes by version of their introduction
# compiled by Tom Christiansen
v1.0 \0, \0N,\0NN Match octal character up to octal 077.
v1.0 \N, \NN, \NNN Match Nth capture group (decimal) if not in charclass and that many seen, else (octal) character up to octal 377.
v4.0 \a Match the alert character (ALERT, BEL).
v5.0 \A True at the beginning of a string only, not in charclass.
v1.0 \b Match the backspace char (BACKSPACE, BS) in charclass only.
v1.0 \b True at Unicode word boundary, outside of charclass only.
v1.0 \B True when not at Unicode word boundary, not in charclass.
v4.0 \cX Match ASCII control character Control-X (\cZ, \c[, \c?, etc).
v5.6 \C Match one byte (C char) even in UTF‑8 (dangerous!), not in charclass.
@briandfoy
briandfoy / gitify.pl
Created April 6, 2012 05:05
Filter my big SourceForge SVN into separate Github projects
# I created this to translate a bunch of projects I had in one big git
# repo into separate repos. The big git repo was converted from the SVN
# repo of my old SourceForge project.
use v5.14;
use strict;
use warnings;
use File::Spec::Functions;
use File::Path qw(remove_tree);
@briandfoy
briandfoy / transmission-mojo.pl
Created April 16, 2012 10:20
Mojo::UserAgent interacting with Mac app Tranmission's RPC
use v5.10;
use utf8;
use strict;
use warnings;
# https://trac.transmissionbt.com/browser/branches/1.7x/doc/rpc-spec.txt
use Mojo::UserAgent;
use JSON qw(to_json);
@briandfoy
briandfoy / gist:3058464
Created July 6, 2012 06:45
Switch file names
#!perl
die "Two files only!\n" if @ARGV != 2;
rename $ARGV[0] => my $temp = "$ARGV[0].bak";
rename $ARGV[1] => $ARGV[0];
rename $temp => $ARGV[1];
#!/usr/bin/perl
use warnings;
use strict;
use Cwd;
use Digest::MD5;
my $md5 = Digest::MD5->new();
my %digests = ();
#!/usr/bin/perl
use File::Find;
use Digest::MD5;
find( \&wanted, grep { -e } @ARGV );
our %digests;
sub wanted {
return if( -d $File::Find::name or -l $File::Find::name );
@briandfoy
briandfoy / find_unused_subs.pl
Created July 7, 2012 00:51
Find unused Perl subroutines
#!/usr/bin/perl
use v5.14;
use strict;
use warnings;
use PPI;
use Scalar::Util qw(blessed);
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
@briandfoy
briandfoy / gist:3068953
Created July 8, 2012 01:48
Download from TiVo
#!/usr/bin/perl -s
use strict;
use warnings;
use Data::Dumper;
use DBM::Deep;
use Net::TiVo;
our $S;
@briandfoy
briandfoy / perl_module_checklist.pl
Created July 24, 2012 01:20
Perl Module Checklist
#!/usr/bin/perl
use strict;
use warnings;
use vars qw( $Longest_name );
use Data::Dumper;
use File::Spec::Functions qw(catfile);
use Spreadsheet::WriteExcel;
use Test::Manifest qw(get_t_files);