Difference between revisions of "Skel.pl"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) (Created page with '=Skeleton PERL Script= <pre> $ cat skel.pl #!/usr/bin/env perl #--------------------------------------------------------------------------- require Getopt::Std; #------------...') |
(No difference)
|
Latest revision as of 16:46, 4 September 2009
Skeleton PERL Script
$ cat skel.pl
#!/usr/bin/env perl
#---------------------------------------------------------------------------
require Getopt::Std;
#---------------------------------------------------------------------------
$usage = qq(\
Usage:
# skel.pl [-d] [-f <file>] [-v]
);
#---------------------------------------------------------------------------
my %opts = ();
my $debug_lvl = 0;
#---------------------------------------------------------------------------
sub getargs
{
Getopt::Std::getopts('dD:vf:h', \%opts);
for my $opt (keys(%opts)) {
if ($opt eq 'd') {
$debug_lvl++;
next;
}
if ($opt eq 'D') {
$debug_lvl = $opts{D};
next;
}
if ($opt eq 'h') {
printf("%s\n", $usage);
exit(0);
next;
}
}
} # getargs
#---------------------------------------------------------------------------
sub main
{
getargs();
if (defined($opts{f})) {
printf("file -> %s\n", $opts{f});
}
if ($debug_lvl > 0) {
printf("Debug Level = %d\n", $debug_lvl);
}
}
#---------------------------------------------------------------------------
main()
#---------------------------------------------------------------------------