[Omaha.pm] Getopt::Long and opt_ variables

Dave Thacker dthacker9 at cox.net
Sat May 28 23:15:26 PDT 2005


In the second edition camel (on page 448), it says that" "If no linkage is 
explicitly specified and no hash ref is passed, GetOptions() will put the 
value of in a global variable named after the option preceded by opt_..." 
Is this automagically done? This example doesn't seen to work .

#!/usr/bin/perl -w

use strict;
use Getopt::Long;
my $opt_place;

&GetOptions("place=s");

print "Hello! $opt_place\n";

dthacker at fluffy:~/dev/dwofl/bin> ./test2.pl -place World Use of uninitialized 
value in concatenation (.) or string at ./test2.pl line 9. Hello!

DT



More information about the Omaha-pm mailing list