• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

Perl User Input Question

Dear Experts,

Objective: to store user input $1 and $2 in two different variables

Goal: execute the script with the below command

#prodcredclnt.pl U12345 25.00

Question: How do I store U12345 into a variable $acctnum and 25.00 in a variable name $diffamnt?

My poor attempt:
@arr = <STDIN>
$acctnum = $arr[0];
$diffamnt = $arr[1];

Question: what is the easiest way to accomplish this?

Many thanks for your help,
James Chen
0
Charley420
Asked:
Charley420
1 Solution
 
ozoCommented:
my($acctnum,$diffamnt) = @ARGV;
0
 
TintinCommented:
And if you want to check you have the right number of parameters, do:

die "Usage $0 [acctnum] [diffamnt]\n" unless $#ARGV == 1;
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now