Using Google Command Line Tools to post my Computer Systems Notes

Below is some code I wrote to post my Computer Systems notes online every day after class:


  1 #!/usr/bin/env perl
  2 use strict;
  3 use warnings;
  4 
  5 unless(defined $ARGV[0]){
  6    print "$0 [file to post]\n";
  7    exit;
  8 }
  9 my @date = ($1,$2,$3) if $ARGV[0] =~ m/Computer_Systems_(\d{4})(\d{2})(\d{2}).txt/g ;
 10 my $title = "Computer Systems Class Notes ".join('/',@date);
 11 my @infile = `cat $ARGV[0]`;
 12 my @template = `cat blank.html`;
 13 # Get rid of blank lines...
 14 my $tmp = pop(@infile);
 15 while($tmp =~ m/^\s*$/g){
 16    $tmp = pop(@infile);
 17    #print "tmp got $tmp\n";
 18 }
 19 push(@infile,$tmp);
 20 open(FH,">$ARGV[0].html");
 21 foreach(@template){
 22    if(m/{{{TITLE}}}/g){
 23       $_ =~ s/{{{TITLE}}}/$title/g;
 24    }
 25    if(m/{{{BODY}}}/g){
 26       $_ =~ s/{{{BODY}}}/@infile/g;
 27    }
 28    if(m/^\s*$/g){
 29       next;
 30    }
 31    print FH "$_";
 32 }
 33    close(FH);
 34 #  
 35 print "google blogger --blog \"Renaissance Engineer\" post --title \"$title\" --tags \"HCS12, Assembly, Computer, Systems, googlecl, development\" $ARGV[0].html\n";
 36 system("google blogger --blog \"Renaissance Engineer\" post --title \"$title\" --tags \"HCS12, Assembly, Computer, Systems, googlecl, development\" $ARGV[0].html");
 37 unlink("$ARGV[0].html");

Comments

Popular posts from this blog

Using Audacity as an Oscilloscope

Ping utility that targets a specific port