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
-moxIn reply to A quick Getopt::Long question by chinamox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |