in reply to Code Cleanup challenge!

Here's another suggestion. You can use Getopt and POD (plain ond documentation). All of your command line options are stored in a single hash for easy lookup.
use strict; use warnings; use Getopt::Long; use Pod::Usage; # Process and validate the command line options in @ARGV. my %options; my $parse = new Getopt::Long::Parser; if (!($parse->getoptions('infile=s', \($options{infile}), 'outfile=s', \($options{outfile}), 'help', \($options{help})))) { help(); } if (not defined($options{infile})) { help(); } sub help { pod2usage(0); } __END__ =head1 NAME A.pl - Creates A file =head1 SYNOPSIS A.pl [options] Options: --infile=[file] --help =over 3 =item B<--infile -i=[file]> A file that is used for input, wildcards are allowed =item B<--outfile -o=[file]> Optional parameter for the output file =item B<--help -h -?> Print a brief help message and exits. =head1 DESCRIPTION B<This program> creates a A files. =cut

Replies are listed 'Best First'.
Re: Code Cleanup challenge!
by kesterkester (Hermit) on Aug 12, 2003 at 17:33 UTC
    As long as the options are all being stored in one hash anyhow, I think the reference-to-options-hash usage of Getopts::Long is easier to read:
    [snip] # Process and validate the command line options in @ARGV. my %options; GetOptions ( \%options, qw{ infile=s outfile=s help } ) or help(); [snip]