Discussion Locked

Use Getopt::Std to parse options

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Do you frequently write Perl scripts that are controlled by command-line options? Will this tip help you parse those command-line options?

4 replies

by richard l.

While another respondent seemed to be critical of this post, I found it helpful. I knew about getopts existence, but didn't take the trouble to look up exactly how to use it. So I write my own in apps that need arguments. Now that I've read this neat little exposition, I'll be more sensible and pop in two lines by rote instead of wasting time reinventing the wheel.

by nishi

The example code seems to work fine but if I turn 'use strict' on, I need to pre-define the vars $opt_m, $opt_f and $opt_s before I can use them. I am not getting the expected results in that case. Since I have 'use strict' all the time, I am wondering if there is a work around this problem.

This discussion is closed to new replies.