Skip to content

Instantly share code, notes, and snippets.

@tene
Forked from djanatyn/returnvalues.pl
Created July 18, 2011 02:53
Show Gist options
  • Save tene/1088461 to your computer and use it in GitHub Desktop.
Save tene/1088461 to your computer and use it in GitHub Desktop.
I can't believe this worked.
#!/usr/bin/perl
use v5.10;
use IO::File qw//;
sub countItems {
(my $target) = @_;
my $fh = IO::File->new('.ptd', 'r') or die 'no .ptd file found';
return map { /^$target:(.*)/ } <$fh>;
}
sub printTodo {
my @todo = countItems('todo'); my @done = countItems('done');
my $t = 1; my $d = 1;
say 'todo:';
for my $todo (@todo) { print "$t:$todo"; $t++; }
say 'done:';
for my $done (@done) { print "$d:$done"; $d++; }
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment