chinamox has asked for the wisdom of the Perl Monks concerning the following question:
I have the sinking feeling that this is going to be a silly newbie question, but I have gone hunting thru the perldocs and supersearch and I can't find a ready answer, so here goes...
I spent a good chunk of today writing a program for an online class and now I have run into a silly little gremlin. I want to give the user the option of calling a striphtml subroutine, but for some reason when I input this:
myusername$: perl myprogram.pl --striphtml someuserinput
My program runs the main subroutine and not the striphtml subroutine. But if I delete main(), then that same command line input runs fine.
Basically all, I want is to have sub main to run if there are no Getopt::Long arguments and conversely, only have sub striphtml run when the user specifies that option.
This is the basic layout of the program
#!/opt/bin/perl -w # # use strict; use Getopt::Long qw(GetOptions); use Pod::Usage qw(pod2usage); my $vars; my @morevars; GetOptions("striphtml" => sub { striphtml() }); main(); exit(); sub main{...} sub striphtml{...}
Thank you for your time and help
-mox
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A quick Getopt::Long question
by jdporter (Paladin) on Nov 22, 2006 at 15:07 UTC | |
|
Re: A quick Getopt::Long question
by philcrow (Priest) on Nov 22, 2006 at 14:50 UTC | |
by chinamox (Scribe) on Nov 22, 2006 at 16:03 UTC | |
|
Re: A quick Getopt::Long question
by Anonymous Monk on Nov 22, 2006 at 14:48 UTC | |
by chinamox (Scribe) on Nov 22, 2006 at 16:08 UTC |