version 1.15, 2010/01/12 20:30:55 |
version 1.18, 2010/01/19 18:53:36 |
|
|
#!/usr/bin/perl |
#!/usr/bin/perl |
# $AFresh1: todo.pl,v 1.14 2010/01/11 19:52:06 andrew Exp $ |
# $AFresh1: todo.pl,v 1.17 2010/01/16 06:07:13 andrew Exp $ |
######################################################################## |
######################################################################## |
# todo.pl *** a perl version of todo.sh. Uses Text::Todo. |
# todo.pl *** a perl version of todo.sh. Uses Text::Todo. |
# |
# |
|
|
use strict; |
use strict; |
use warnings; |
use warnings; |
|
|
use Data::Dumper; |
|
|
|
use Getopt::Std; |
use Getopt::Std; |
use Text::Todo; |
use Text::Todo; |
|
|
use version; our $VERSION = qv('0.0.1'); |
use version; our $VERSION = qv('0.1.0'); |
|
|
# option defaults |
# option defaults |
my $config_file = $ENV{HOME} . '/todo.cfg'; |
my $config_file = $ENV{HOME} . '/todo.cfg'; |
|
|
|
|
if ( exists $actions{$action} ) { |
if ( exists $actions{$action} ) { |
my $config = read_config($config_file); |
my $config = read_config($config_file); |
my $action = $actions{$action}->( $config, @ARGV ); |
my $result = $actions{$action}->( $config, @ARGV ); |
} |
} |
else { |
else { |
usage(); |
usage(); |
|
|
my @pri_list; |
my @pri_list; |
if ($pri) { |
if ($pri) { |
$pri = uc $pri; |
$pri = uc $pri; |
if ( $pri !~ /^[A-Z]$/xms ) { |
if ( $pri !~ /^[[:upper:]]$/xms ) { |
die "usage: todo.pl listpri PRIORITY\n", |
die "usage: todo.pl listpri PRIORITY\n", |
"note: PRIORITY must a single letter from A to Z.\n"; |
"note: PRIORITY must a single letter from A to Z.\n"; |
} |
} |
|
|
if ( !( $line && $line =~ /^\d+$/xms && $priority ) ) { |
if ( !( $line && $line =~ /^\d+$/xms && $priority ) ) { |
die "$error\n"; |
die "$error\n"; |
} |
} |
elsif ( $priority !~ /^[A-Z]$/xms ) { |
elsif ( $priority !~ /^[[:upper:]]$/xms ) { |
$error .= "\n" . 'note: PRIORITY must a single letter from A to Z.'; |
$error .= "\n" . 'note: PRIORITY must a single letter from A to Z.'; |
die "$error\n"; |
die "$error\n"; |
} |
} |