Please rate my scripts.

Alan Young alansyoungiii at gmail.com
Tue Apr 15 07:45:33 MDT 2008


I couldn't resist--here's a more idiomatic perl version:

#!/usr/bin/perl

use strict;
use warnings;

use Cwd 'abs_path';
use File::Basename;

use constant DIR  => dirname( dirname( __FILE__ ) );
use constant DICT => abs_path( DIR.'/doc/aspell.en.pws' );

sub spellcheck {
    my $file = shift;
    print "Spell checking $file\n";
    system('aspell', '-H', '-p', DICT, '-c', $file);
}

if ( ( @ARGV == 0 ) || ( ( @ARGV == 1 ) && ! -f $ARGV[0] ) ) {

    my $treeish = $ARGV[0] || 'master';

    open ( GIT, "git diff --name-only '$treeish'|" )
        or die "Unable to open $treeish: $!";

    chomp ( my @files = <GIT> );

    spellcheck( $_ ) for grep { m{.*/.*\.xml$} } @files;

} else {

    spellcheck( $_ ) for @ARGV;

}

-- 
Alan



More information about the PLUG mailing list