use Getopt::Long; use Data::Validator; my $tweet_id; my $print_key; my $help; GetOptions('i=i' => \$tweet_id, 'p=s' => \$print_key, h => \$help); if ($help) { die show_help(); } validate( tweet_id => $tweet_id, print_key => $print_key ); sub validate { eval { state $rule = Data::Validator->new( tweet_id => { isa => 'Int' }, print_key => { isa => 'Str' }, ); my $args = $rule->validate(@_); }; if ($@) { die show_help(); exit; } } sub show_help { my $help_doc = <<EOF; get retweet info script Usage: perl $0 [options] Options: -i : tweet_id (Int) -p : print_key (Str) ex ) id, screen_name, location https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-show -h : help Author okkun_sh <okkun.sh\@gmail.com> (\@okkun_sh on Twitter) EOF return $help_doc; }