diff --git a/todo b/todo index 1b793f1..a9176ea 100644 --- a/todo +++ b/todo @@ -1,5 +1,7 @@ #!/usr/bin/perl +# simple TODO-manager + use strict; use warnings "all"; use 5.10.0; @@ -29,7 +31,6 @@ if ($help) { } if ($delete) { - say Dumper(\@ARGV); die "NUM not set\n" if ($ARGV[0] !~ /^\d+$/); my @TODO = readtodo(); die "NUM too big\n" if ($ARGV[0] > @TODO); @@ -48,20 +49,25 @@ if ($delete) { close TD; } else { - die "Specify what to put in memo\n" unless (@ARGV > 0); - my @TODO = readtodo(); - push @TODO, join(" ", @ARGV); - open (TD, ">", $file) or die "Unable to open $file: $!\n"; + if (@ARGV > 0) { + push @TODO, join(" ", @ARGV); + open (TD, ">", $file) or die "Unable to open $file: $!\n"; - for (my $i = 0; $i < @TODO; $i++) { - next unless (defined($TODO[$i])); - print sprintf("%s. %s\n", $i, $TODO[$i]); - print TD sprintf("%s. %s\n", $i, $TODO[$i]); + for (my $i = 0; $i < @TODO; $i++) { + next unless (defined($TODO[$i])); + print sprintf("%s. %s\n", $i, $TODO[$i]); + print TD sprintf("%s. %s\n", $i, $TODO[$i]); + } + + close TD; + } else { + for (my $i = 0; $i < @TODO; $i++) { + next unless (defined($TODO[$i])); + print sprintf("%s. %s\n", $i, $TODO[$i]); + } } - - close TD; } exit 0;