Waste of Space

Just another weblog

getopts() problem in perl

Posted by Vaibhav Patle on May 24, 2007

Recently I was working on a perl script and had issues while getting command line parameters using function getopts(). I have perl version 5.003_07 installed on my machine.
The script was

use Getopt::Std;
getopts(‘u:p:a:o:f:’);

I spent lot of time analysing this issue. Finally I was able to fix the problem and want to post it somewhere for others who may face similar problem.

There was problem with .pl file association in Windows. You have to tell Windows to use the entire command line as arguments to the interpreter.

Follow following steps :-
1. Open the Windows Explorer and click on Tools -> Folder Options -> File Types.
2. Find the PL extension, and highlight it. 
3. If you see the Restore button, click on it.
4. Click on Advanced.  Find the action that runs the script (“Run” or “Open”) and click Edit.
5. Under “Application used to perform action;”, type:
C:\Perl\bin\perl.exe “%1″ %*
6. Click Ok out of all the boxes.

The problem should go away now.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>