473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Using Getopt::EvaP to parse command-line arguments

I'm new to PERL, and am trying to use the Getopt::EvaP module to parse my command-line arguments, but I am a little lost as to how to make this work.

So far I have downloaded and installed the module, and added the following to my script:

Expand|Select|Wrap|Line Numbers
  1. use Getopt::EvaP;
Now, I'm not sure where I add the PDT syntax; does this go in my script, or is it an external file? So there's PDT, MM, and OPT that I need to specify to make this work.

Could someone please post a very basic working example of using this module, so that I can get a handle on how I can make it work in my script?

Any help would be very appreciated.
May 28 '07 #1
7 2431
miller
1,089 Expert 1GB
The only advice that I have to give is to not use Getopt::EvaP. The most standard module that I know to use is Getopt::Long. The other module hasn't been updated since 1999.

cpan Getopt::Long

There are plenty of examples and documentation provided in that module.

- Miller
May 28 '07 #2
Thank you. I'll try with that when I get home.
May 28 '07 #3
numberwhun
3,509 Expert Mod 2GB
Also, in the spirit of TMTOWTDI:

Keep in mind that you command line arguments are automatically plugged into the special array @ARGV.

So, if you are just wanting someone to supply a file name, then you can get that file name into a variable by using:

$varName = "@ARGV[0]";

In addition, you can check to see if @ARGV has the required number of elements. Lets say that you have a requirement that 4 parameters must be specified to the script, then you could use the following to check that:

if ($#ARGV != 4)
{
print usage statement;
}

The $#ARGV contains the number of elements in @ARGV. After than, you could test each argument for what might be expected or just move on to the next step, its up to you.

Hope this helps.

Regards,

jlk
May 29 '07 #4
KevinADC
4,059 Expert 2GB
$#ARGV would be the index number of the last element of @ARGV, which is one less than the length of the array. So for four arguments:

Expand|Select|Wrap|Line Numbers
  1. if ($#ARGV != 3) {
  2.     error message
  3. }
May 29 '07 #5
numberwhun
3,509 Expert Mod 2GB
$#ARGV would be the index number of the last element of @ARGV, which is one less than the length of the array. So for four arguments:

Expand|Select|Wrap|Line Numbers
  1. if ($#ARGV != 3) {
  2.     error message
  3. }

DOH!!! You are correct. I swear I have to start running things under your scanner to see if I mis-spoke before hitting "Submit Reply". :-)

jlk
May 29 '07 #6
Thank you, everyone, for your replies...

I changed to Getopt::Long and all is rosey again. Good documentation and excellent results. It's a handy module.
May 30 '07 #7
miller
1,089 Expert 1GB
Excellent.

Glad that we could help.

- Miller
May 30 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bruno Alexandre | last post by:
Hi guys, withou using SP, I want to be able to add a Parameter to the SQL Query and retrive the Recordset so I can use the Paging property under the recorset object.... how can I do this? I'm...
0
by: Mukesh Kumar | last post by:
hi all, I have created some independent reports through crystal reports developer edition v 10 and developed a small tool in .net framework v 1.1 to view these reports through the crystal reports...
1
by: bjbounce2002 | last post by:
Hello, I am using forms with command buttons to close form or run action queries. The error messages such as "Null value in required field" or "duplicate value in primary key" are suppressed....
4
by: sirimanna | last post by:
hi, Is any one can help me to open files in my computer(for an example: some word document)using command button... i want to open file's using my vb programme..but i can't do it...can any one...
3
by: BLUE | last post by:
DbParameter dateAndTime = this.factory.CreateParameter(); dateAndTime.ParameterName = "@DateAndTime"; dateAndTime.DbType = DbType.DateTime; string utcDtString =...
2
by: tejavenkat | last post by:
Hi, I have one scenario i.e Download as csv is there it is a command button when we click on this the save dialog box should be open,Am using javascript how can we do this by using by javascrpt...
1
by: Josec84 | last post by:
Im writing a script and need help. I need to extract a file using the command prompt. Are there commands to extract files or unzip files(without downloading any add-ons)??? Let's say i have a file...
0
by: mesadobes | last post by:
I am very new to visual basic. Actually, I have no clue what I'm doing! But I know what I want to do. I am trying to learn as I go... How do I create a command button that when clicked will...
3
by: Israel | last post by:
I always wondered why the using command can only take one object. I always find that this isn't sufficient for drawing so I end up always disposing in my finally block but then I have to remember...
0
by: swightness | last post by:
Can i log into hercules from command prompt Can i execute a file in my hercules folder using the command prompt Windows XP Thank you John
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.