O, Ye who are faithful, I beseech thee aid this lowly initiate...
For some reason I don not understand, I get an 'unitialized value' warning everywhere $args is used...even when I pass in arguments.
I'm sure is some simple thing I've overlooked, but no idea what that simple thing is.
#!/usr/bin/perl -wT
use Getopt::Std;
use Getopt::Long;
GetOptions( "help" => \$help,
"file=s" => \$file,
"database=s" => \$database,
"user=s" => \$user,
"password=s" => \$password);
#-h ARG, -f ARG, -d ARG, -u ARG, -p ARG sets $args{h},sets $args{f}, s
+ets $args{d}, sets $args{u}, sets $args{p}
getopts("hf:d:u:p:", \%args);
if ($args>=2){
$help=$args{h};
$file=$args{f};
$database=$args{d};
$user=$args{u};
$password=$args{p};
}elsif ($help){
print "rip_sched -h/--help -f/--file datafile -d/--database databa
+se -u/--user database-user -p/--password database-password\n";
exit 0;
}
In reply to getopt?
by azool
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.