L8on has asked for the wisdom of the Perl Monks concerning the following question:
I must be just a goober, but I can't seem to figure out how to use the variables from a module while using use strict;
I have this snippet of code:
#!/usr/bin/perl -w use strict; use Getopt::Std; getopts('hd:t'); my ($num_days, $dait, $today); # local vars used later my ($opt_h, $opt_d); # vars from Getopt::Std # if I don't use my() here I get the following #Global symbol "$opt_h" requires explicit package name at ./checklogs. +pl line 12. #Global symbol "$opt_d" requires explicit package name at ./checklogs. +pl line 13. # I tried Getopt::Std::$opt_h and it didn't like it either. # if ( $opt_d ) { $num_days = $opt_d; } print ("num_days = $num_days\n");
$opt_d never gets initialized when I use my(); I'm assuming that it is creating the variable locally and not from the package. How do I get the variables from the package Getopt::Std into my program?
Any help would be greatly appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: how do i use module vars while using use strict; ?
by jeffa (Bishop) on Apr 10, 2001 at 18:33 UTC | |
|
Re: how do i use module vars while using use strict; ?
by davorg (Chancellor) on Apr 10, 2001 at 18:41 UTC | |
|
Re: how do i use module vars while using use strict; ?
by Caillte (Friar) on Apr 10, 2001 at 18:43 UTC | |
|
Re: how do i use module vars while using use strict; ?
by Rhandom (Curate) on Apr 10, 2001 at 19:35 UTC |