Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (44 sloc) 1.384 kb

Title: Something New
Author: Chris Prather Date: 2006-05-09 01:07:04

Something New

I wrote a little program tonight that takes input from STDIN and posts to this blog using Net::Blogger (obviously if you're reading this it worked). Because it reads from STDIN it works nicely with TextMate. W00t. Here's the text of the script (posted using: cat which blog | mate | blog --title "Something New") #!/usr/bin/perl use strict; use warnings; use version; our $VERSION = qv("1.0.0"); use Carp; use Config::Auto; use Getopt::Long; use Net::Blogger

$Config::Auto::Untaint = 1;
my %conf = %{ Config::Auto::parse( '.blogrc', format => "yaml" ) };
my %opt;
GetOptions( 
    \%opt,
    'sitename=s',
    'title=s',
    'catagory=s',
    'proxy=s',
    'domain=s',
    'type=s',
    'username=s',
    'password=s',
);
$opt{sitename} ||= $conf{default};
%opt = ( %{ $conf{ $opt{sitename} } }, %opt);
{ local $/; $opt{postbody} = <> }

my $mt = Net::Blogger->new(engine=>$opt{type});
$mt->Proxy("http://$opt{proxy}");
$mt->Username($opt{username});
$mt->Password($opt{password});
$mt->BlogId($opt{blogid});

my $id = $mt->metaWeblog()
            ->newPost(
                title=>$opt{title},
                description=>$opt{description},
                publish=>1
            ) || croak $mt->LastError();

__END__
Jump to Line
Something went wrong with that request. Please try again.