Perl User Input Question

Posted on 2005-03-02
Medium Priority
Last Modified: 2010-03-05
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
Question by:Charley420
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 84

Accepted Solution

ozo earned 300 total points
ID: 13455698
my($acctnum,$diffamnt) = @ARGV;
LVL 48

Expert Comment

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

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question