I don't recommend writing applications that interact with a user, asking the user to enter data. Such applications may seem beneficial to the end user, but not if that end user is another application. Rather, use tools that provide a means to accomplish both readability (for humans) and non-inter-activeness (for non-humans). In other words, consider using command line arguments over reading in "raw" STDIN.

#!/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

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Re: Stdin for just numbers. (use Getopt::Long) by jeffa
in thread Stdin for just numbers. by programmercarlito

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.