Link to home
Start Free TrialLog in
Avatar of Charley420
Charley420

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tintin
Tintin

And if you want to check you have the right number of parameters, do:

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