Thanks for the suggestions. Your help was much appreciated. I ended using
"book" =>\$book, instead of book=s in my code.
After that my script no longer expected the string, which is good news.
Thanks to you both for helping me with that. I can continue
to script away again :)
-T
> >
> >
> > ----- Original Message -----
> > From: "Trina Espinoza" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tuesday, September 23, 2003 6:10 PM
> > Subject: GetOpts: boolean and argument value combos
> >
> >
> > 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";
> >
> > }
> >
> >
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]