#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; use Getopt::Long; use Pod::Usage; my @opts = qw( starting-amount current-age retire-age deposit interest expected ); GetOptions ( ( \my %args => map "$_=i", @opts ), 'help' => \my $help, 'man' => \my $man, ); pod2usage( -verbose => 1 ) if $help; pod2usage( -verbose => 2 ) if $man; for (@opts) { pod2usage( -msg => "$_ is required", -exitval => -1, -verbose => 0, ) unless defined $args{$_}; } pod2usage( -msg => "retire-age must be greater than current-age", -exitval => -1, -verbose => 0, ) if $args{'retire-age'} <= $args{'current-age'}; print Dumper \%args; __END__ =head1 NAME retirement-calculator - app to calculate retirement amount =head1 SYNOPSIS retirement-calculator [options] Options: --starting-amount the amount to start retirement with --current-age how old you currently are --retire-age what age you want to retire at --deposit amount deposited per year --interest annual interest rate --expected what you expect to retire with --help list usage --man print man page =cut