Caroline Allen wrote:
>
> Hi, my name is Caroline Allen, and I'm a fairly long-time C programmer,
> predominantly in the field of visual effects (you know, like, hacking
> for movies). I have recently started using Perl, and I think it's
> _great_, though getting up to speed with it is a bit like when I started
> learning Spanish long after being fluent in French -- Perl has so many
> similarities to C and <n>shell that I trip over the differences. Things
> only get more confused because I'm also a Lisp programmer, and a lot of
> the dynamic/lexical scoping issues are very familiar to me, not to
> mention the automatic memory management. Oh gosh, then there's Basic and
> its own way of string handling (I was doing a lot of work in VB). As one
> of my clients, Daffy Duck, would say, "Mother!"
>
> I would really like to be using "getopt," and I'm failing. I can't
> submit examples of my code to this list, for facility security reasons,
> but if anyone could post some sample code using "getopt", or direct me
> _to_ some sample code, that would be great. I browsed CPAN but didn't
> find anything to the purpose, and I get the feeling that The Camel book
> doesn't really address this very much, at least as far as I can find. I
> would like to be using "getopt" because it models the behavior my client
> base is accustomed to, i.e. switch-based, non-positional arguments on
> the UNIX command line.
>
> I can't help wondering: does the Perl community have the same distaste
> for non-positional arguments as the Lisp community seems to have?
>
> Thanks in advance,
> Working on a Friday night, waiting for the hellish traffic to subside,
You don't say whether you are using Getopt::Std or Getopt::Long so I'll
assume Std.
use Getopt::Std;
my %options;
getopts( 'hf:', \%options );
if ( exists $options{h} ) {
die <<HELP;
usage: $0 [-h] [-f filename]
-h print this help message
-f filename process this file
HELP
}
if ( exists $options{f} ) {
open my $fh, $options{f} or die "Cannot open $options{f}: $!";
# do something with file contents
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]