Use Getopt::Long:
#!/usr/bin/perl
use warnings;
use strict;
use Term::ReadKey;
use JSON::RPC::Client;
use Getopt::Long;
GetOptions \my %opts,
'--host=s',
'--port=s',
'--user=s' or
die 'getopt';
print 'RPC password: ';
ReadMode 'noecho'; $opts{'pass'} = <>; ReadMode 'restore'; print "\n";
chomp $opts{'pass'};
my $url = sprintf 'http://%s:%s@%s:%s/', @opts{qw/user pass host port/};
my $rpc = JSON::RPC::Client->new;
$rpc->prepare ($url, [ qw/getblock getblockhash/ ]);
my $bh = $rpc->getblockhash (222222);
my $block = $rpc->getblock ($bh);
my @tx = @{ $block->{'tx'} };
printf "%d txs\n", scalar @tx;
$ ./getopt-rpc.pl --user user --host localhost --port 8332
RPC password:
749 txs
$ ./getopt-rpc.pl -u user -h localhost -p 8332 ## short options are ok too
RPC password:
749 txs
Regarding the SSL bit, I lack motivation.