From: mitty Date: Sat, 18 Dec 2010 15:11:03 +0000 (+0000) Subject: * pack usage message to $help = sub {...} X-Git-Url: http://lab.mitty.jp/git/?a=commitdiff_plain;h=fe7588333fde0d1dba7162596725ea5f269b68ab;p=lab.git * pack usage message to $help = sub {...} * remove needless '\n' and "done\n" git-svn-id: https://lab.mitty.jp/svn/lab/trunk@98 7d2118f6-f56c-43e7-95a2-4bb3031d96e7 --- diff --git a/Dev/twitter/dump_timeline.pl b/Dev/twitter/dump_timeline.pl index 246a1d4..8216287 100755 --- a/Dev/twitter/dump_timeline.pl +++ b/Dev/twitter/dump_timeline.pl @@ -15,7 +15,7 @@ use YAML::Tiny; use Data::Dumper; use Encode; -if ($ARGV[0] && ($ARGV[0] eq '--help' || $ARGV[0] eq '-h') ) { +my $help = sub { die <authorized) { - die "$0: this client is not yet authorized.\n"; + die "$0: this client is not yet authorized."; } @@ -67,7 +71,8 @@ eval { $res = $bot->mentions($param); } else { - die "$0: unknown method => $method\n"; + warn "$0: unknown method '$method'"; + &{$help}; } if ($dump) { @@ -92,7 +97,6 @@ eval { if ($@) { evalrescue($@); } -print "done\n"; sub loadconf { @@ -105,7 +109,7 @@ sub loadconf { my $yaml = YAML::Tiny->read($file); if ($!) { - warn "$0: '$file' $!\n"; + warn "$0: '$file' $!"; } return $yaml->[0];