in reply to Reading command line flags into variables...?

While those modules do what you want, there is a learning curve involved, and they can some times be over kill. If all you need is to say, get the name a user then:
die "usage: script.pl firstName lastName\n" unless 2 == @ARGV; my ( $firstName, $lastName ) = @ARGV;
Of course, if you want a fancier level of flag passing, such as optional parameters, then I recommend using one of the previously mentioned modules. I have rolled my own command line parser, and while it was fun, it was also a serious chunk of code. Don't go down that route.

Replies are listed 'Best First'.
(Coyote) Re: Re: Reading command line flags into variables...?
by Coyote (Deacon) on Feb 01, 2001 at 07:52 UTC
    In the example above, $firstName == '-n' and $lastName == 'Bob'. The command line flags are elements in @ARGV. Getopt::Std takes care of this for you. Also, if you are parsing the command line options by hand, you have to be aware of the order which the arguments were passed to the script.

    Update: I didn't read Adam's post closely enough to notice that he was not using command line flags. My apologies.

    ----
    Coyote