Archive for the ‘perl’ Category

automatically generate change file from cvs

Wednesday, June 25th, 2008

So I had Mark Stosberg note that HTML::Template::Default had no Changes file.

I keep everything in cvs because .. Because otherwise I think I would be in a mental instituion.

So, cvs records changes if you tell it something- as you commit changes.

There is a specific gnu format for a changes file. You will see changefiles in distros like CGI, CGI::Application.. most good distros. And it makes sense, to keep track of stuff. People might want to know what’s up and why. And often I do add comments to my commits.
But, do I have to write this tedious file by hand? Maybe there’s an automatic way to generate this…
(more…)

Stop getting windows cpan fail reports

Sunday, June 8th, 2008

I’ve noticed I’ve been getting more fail reports from CPAN on some basic modules.
Things like File::PathInfo and LEOCHARRE::CLI, things I clearly intended for POSIX only portability. You see- most of these fail reports are from mswin32 platforms. M$ land.
I have zero interest in porting anything to windows. I resent that perl was ported.. or whatever did happen.. to m$ platforms.

I have gone back and made sure to place some hacks to stop my modules from even intalling on mswin32 platforms.
(more…)

cli pdfmerge

Friday, June 6th, 2008

I have a working release of pdfmerge.

My goodness! Why another pdf merging thingie!!!!

This one counts how many pages are in all docs, then compares to output, etc.. Anyhow, it’s somewhat safe.
And it’s a simple call. Instead of looking up how to use xpdf or something to merge pdfs, you can use pdfmerge via the command line. Yes, there *is* another pdfmerge out there. In fact like 2. One requires extra moolah for the ‘full’ version.. pleeezzz…
(more…)

How to add runmodes to a CGI::Application

Tuesday, March 25th, 2008

There really are a ton of messy ways to tinker with adding runmodes to CGI::Application.

I tried a lot of different things, succesfully, strangely, even ‘cleverly’.

If you have a plugin that is being ‘use’d, you should have an import function.

(more…)

posting to wordpress via the command line

Sunday, January 20th, 2008

I tackled this problem via XMLRPC and perl.
I ended up packaging this under WordPress::Post on cpan.

Usage examples:

wppost -t 'title of the post' -c stuff,fruit,cake -i 'This is what I think of bla.'

You can also write a text file, the name of the text file is the title.

wppost -i ./path/to/title_of_the_post.txt

This program is in its infancy. But dammit, it works. It’s how I posted this content via the command like. Also, you can include images in your posts. Multiple images. Via the command line.
Anything not in the argument is considered posting content..
So what if your post if about a party you went to, and you have 5 pictures..

First write your halloween_party.txt file, then have your photos lined up somewhere.. then..

wppost -i halloween_party.txt ./images/halloween_photos_post/*jpg

Done. Linux rocks.

rename images by exif date

Tuesday, January 15th, 2008

I have a digital cam. I take pictures.
I don’t like a million DSCIM or DSCF or whatever files.
It’s inconvenient with so damn many.

It would be nice to rename all the images according to the date, as recorded inside the image exif data, that is, the sate stamp put in by your camera.

I hacked together this script to do that..
Use at your own peril. This is a hack.
Eventually I will release a refined version on cpan.

This scrip requires modules Image::ExifTool, LEOCHARRE::CLI ..

#!/usr/bin/perl -w
use strict;
use File::Copy;
use Cwd;
use LEOCHARRE::CLI;

# requires Image::ExifTool
#
my $o = gopts('m');

#yn('rename all jpg files by date in '.cwd().'?') or exit;

my $files = argv_aspaths();

(defined $files and scalar @$files )or die("no file arguments provided");

if ($o->{m}){
   -d './noout' or mkdir './noout';
}

for (@$files){
   $_=~/(.+)\/([^\/]+)$/ or next;
   my $abs = $1;
   my $filename = $2;
   $filename=~/\.jpg$/i or next;
   print STDERR "$abs   - $filename \n" if DEBUG;

   if ($filename=~/\d{4}[_\: ]+\d{2}[_\: ]+\d{2}/){
      print STDERR "file $filename already named?\n" if DEBUG;
      next;
   }

   my $out =  `exiftool -DateTimeOriginal '$abs/$filename'`;
   chomp $out;

   unless( $out ){
      print STDERR " no out? $filename\n" if DEBUG;
      if ($o->{m}){
         File::Copy::move("$abs/$filename", "$abs/noout/$filename");

      }
      next;

   }
   $out=~s/^Date\/Time Original[\:\s]*//i;
   $out=~s/:| /_/g;

   unless( $out=~/^[\d_]+$/ ){
      print STDERR "dont like [$out]\n" if DEBUG;
      next;
   }   

   print STDERR "$filename : [$out]\n" if DEBUG;;

   rename("$abs/$filename", "$abs/$out\_$filename");
   print STDERR "moved to $abs/$out\_$filename\n" if DEBUG;  

}

=head1 OPTION FLAGS

   -m move to noout dir if cant get date

problems installing DBD::mysql

Saturday, January 12th, 2008

So I was doing a fresh install of my customized database api package for perl. LEOCHARRE::Database.
Goodly enough, my perl Makefile.PL let me know that I was missing DBD::mysql. Great.

I fire up cpan install DBD::mysql, and alas.. No go! How come??

Turns out you need to install mysql-client and mysql-devel.
I’m on a fedora core gui, so I use yum..

yum -y install mysql-client mysql-devel

Great.
Now let’s try cpan again..
cpan install DBD::mysql

It works better.. but oops.. still ..
2 tests skipped.
Failed 31/34 test scripts, 8.82% okay. 473/478 subtests failed, 1.05% okay.
make: *** [test_dynamic] Error 255
/usr/bin/make test -- NOT OK
Running make install
make test had returned bad status, won't install without force

What’s up?
I think the mysql server’s not running on this machine, thus, we need to install to make a full successful check via cpan.

yum -y install mysql-server

And then..
[root@localhost LEOCHARRE-Database]# /etc/init.d/mysqld status
mysqld is stopped
[root@localhost LEOCHARRE-Database]# /etc/init.d/mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
Ok

Great. Let’s try that cpan again..

cpan install DBD::mysql

Haha! It works! :-)