in reply to "Getoptions'" argument syntax

That code is another way of saying:

my $REFRESH = 10; GetOptions( "refresh=i" => \$REFRESH, ...... );

You can think of the my as both representing and declaring the lexical variable(s) in question.

update: The reason it's a =i and not a :i is that the =i makes the number mandatory after the option, but not the option.

Replies are listed 'Best First'.
Re: Re: "Getoptions'" argument syntax
by nysus (Parson) on Jun 15, 2001 at 23:42 UTC
    OK, thanks. But still, if $REFRESH is required to be given a value from command line, why bother setting it to 10? Why not make the command optional with a ":". This is merlyn's code so I'm assuming a guru like that would have some logic behind this but maybe I'm wrong.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot";
    $nysus = $PM . $MCF;

      '=' means that: *If* you give the option you *must*(mandatory) give an argument. To give the option although is *optional*. ':' means you can give the option with or without an argument.