in reply to Re: Sharing Getopts::Std amongst several related scripts
in thread Sharing Getopts::Std amongst several related scripts

Thank you very much for such a comprehensive answer :)

I've changed the code in my library to look like so:

{ package OPTS; use Getopt::Std; our %opts; getopts('fs', \%opts); }
and in the script that requires the library, I have:
our %opts; *opts = \%OPTS::opts; if ($OPTS::opts{f}) { #do stuff }
and it all seems to work now the way I want it to. Although I'm still not really sure I fully understand what's going on here. I've just been flicking through Chapter 10 (Packages) in my trusty Camel Book. I think I need to study it some more before I get the hang of this.

But thanks again :)

Replies are listed 'Best First'.
Re^3: Sharing Getopts::Std amongst several related scripts
by ikegami (Patriarch) on Dec 13, 2005 at 17:31 UTC
    our %opts; *opts = \%OPTS::opts; if ($OPTS::opts{f}) { #do stuff }
    can be simplified to
    if ($OPTS::opts{f}) { #do stuff }
    or
    our %opts; *opts = \%OPTS::opts; if ($opts{f}) { #do stuff }