in reply to Using getopt

Your lexical 'my $opt_i' is masking the package $opt_i that Getopt::Std creates.

Use
use Getopt::Std; use strict; use vars qw/$opt_i/; getopt('i'); print "Increment value is $opt_i\n";


grep
grep> cd pub
grep> more beer

Replies are listed 'Best First'.
Re: Re: Using getopt
by idunno (Beadle) on Jan 24, 2002 at 04:49 UTC
    Thanks for the replies. That works for me now.

    This is getting off the subject, but what exactly is the difference between 'my $opt_i' and the use vars way? And could you point me to where I can read about 'lexical scope' and 'packages'?

    Thanks again.

      Dominus has an excellent article called Coping with Scoping that should help you out. Chapter 5 of the Camel and chapter 6 of the Panther are also relevant.

      --
      :wq