[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Omaha.pm] Getopt::Long and opt_ variables
* Dave Thacker (dthacker9@cox.net) wrote:
> my $opt_place;
It works, just need
our $opt_place;
"my" restricts you to only set/access the value within the class, "our"
lets you set/access the value outside of the class. Also, when it
doubt, "use the source"
perldoc -m Getopt::Long
Thats what I did and just looked for "opt_" and found the following, so
knew the code did as you explained...
else {
# Link to global $opt_XXX variable.
# Make sure a valid perl identifier results.
my $ov = $orig;
$ov =~ s/\W/_/g;
if ( $opctl{$name}[CTL_DEST] == CTL_DEST_ARRAY ) {
print STDERR ("=> link \"$orig\" to \@$pkg","::opt_$ov\n")
if $debug;
eval ("\$linkage{\$orig} = \\\@".$pkg."::opt_$ov;");
}
elsif ( $opctl{$name}[CTL_DEST] == CTL_DEST_HASH ) {
print STDERR ("=> link \"$orig\" to \%$pkg","::opt_$ov\n")
if $debug;
eval ("\$linkage{\$orig} = \\\%".$pkg."::opt_$ov;");
}
else {
print STDERR ("=> link \"$orig\" to \$$pkg","::opt_$ov\n")
if $debug;
eval ("\$linkage{\$orig} = \\\$".$pkg."::opt_$ov;");
}
}
-- Jeff Bisbee / omaha-pm@jbisbee.com / jbisbee.com