From: mitty Date: Wed, 12 Jan 2011 11:08:41 +0000 (+0000) Subject: * "-d" option to print all data except 'undef' X-Git-Url: http://lab.mitty.jp/git/?a=commitdiff_plain;h=679d34a74252816b2d71c3aec6527e5a402d6f16;p=lab.git * "-d" option to print all data except 'undef' git-svn-id: https://lab.mitty.jp/svn/lab/trunk@108 7d2118f6-f56c-43e7-95a2-4bb3031d96e7 --- diff --git a/Dev/twitter/show_status.pl b/Dev/twitter/show_status.pl index 1c76079..22fa3d0 100755 --- a/Dev/twitter/show_status.pl +++ b/Dev/twitter/show_status.pl @@ -14,21 +14,30 @@ use Data::Dumper; my $bot = Net::Twitter::Lite->new; +my $dump; +if (defined $ARGV[0] and $ARGV[0] eq "-d") { + $dump = shift @ARGV; +} + eval { foreach my $id (@ARGV) { + $id =~ /\/?(\d+)$/; + $id = $1; my $res = $bot->show_status($id); foreach my $line (split /\n/, Dumper $res) { if ($line =~ /undef/) { next; } - unless ($line =~ / => {/ - || $line =~ / = / - || $line =~ /status/ - || $line =~ /'text'/ - || $line =~ /created/ - || $line =~ /'id'/ - || $line =~ /name/ - || $line =~ / },/ - || $line =~ / };/ - ) { next; } + if (! $dump) { + unless ($line =~ / => {/ + || $line =~ / = / + || $line =~ /status/ + || $line =~ /'text'/ + || $line =~ /created/ + || $line =~ /'id'/ + || $line =~ /name/ + || $line =~ / },/ + || $line =~ / };/ + ) { next; } + } print $line, "\n"; } } @@ -36,7 +45,6 @@ eval { if ($@) { evalrescue($@); } -print "truncated output done\n"; sub evalrescue {