in reply to Re^2: Stdin for just numbers.
in thread Stdin for just numbers.

You could also use IO::Prompter, which I only recently learned about.

#!/usr/bin/perl use strict; use warnings; use feature qw/say/; use IO::Prompter; my %responses = (); my @prompts = ( ["startamount", "the starting amount", ""], ["startage", "your current age", ""], ["endage", "the age you want to retire", sub { $_ >= $r +esponses{'startage'} } ], ["yearlydeposit", "amount deposited per year", ""], ["annualinterest", "the Annual interest rate", ""], ["expectedmoney", "Expected Retirement Money", ""], ); foreach my $prompt (@prompts) { $responses{$prompt->[0]} = prompt "Enter $prompt->[1]:", -num => $ +prompt->[2] } foreach (sort keys %responses) { say "$_: $responses{$_}"; }

There's probably a better way of specifying empty constraints -- though the OP will likely some constraints that goes beyond "it's a number" imposed on most of the input.