Hey Perl Peps,
I am stuck in the mudd and hoping someone can give me a few clues that will help get
me back on track.
I want to submit some arguments like so:
./script1.pl -book -title HP3 -chapter 04
NOTE: -book does not have an argument
Now I have been using GetOpt::Long and everything works except the first value -book.
Since I want to treat -book like a boolean, I do
not give it value, which causes problems because I guess it needs to receive some sort
of value in it's current format. This is causing problems
where the value of the second argument -title does not show. Is there a syntactical
form I can follow to treat -book like a boolean and feed the other arguments
values? Can I continue to use Getopt::Long?
Any suggestions would be much appreciated.
CODE
-----------------------------------
use Getopt::Long;
use File::Path;
#use strict;
GetOptions (
"book=s" =>\$book,
"magazine=s" =>\$magazine,
"video=s" =>\$video,
"c=s" => \$chapter,
"t=s" => \$title,
);
##Routes to appropriate subroutine
print "SHOW TEST: $sPath\n";
if ($book) {
itemCreator($chapter, $title);
}
###SUBROUTINES
sub showCreator {
my($chapter, $title) = @_;
print "\n";
print "CHAPTER: $chapter\n"; ###Not appearing because -book did not receive
an arguement :(
print "TITLE: $title: $template\n";
}