CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
GetOpt doesn't get option!!



Apr 4, 2000, 4:51 PM

Post #1 of 3 (1366 views)
GetOpt doesn't get option!! Can't Post

Hi is there anyone out ther who can help me with this problem. I've initialised all the option values.

GetOptions ('verify=i' => \$link_verify,
'st|sort=s' => \$sort,
'fl|file=s' => \$file,
'sz|size=i' => \$min_file_size,
'mx|maxhit=i' => \$max_hit,
'd1|mindate=s' => \$min_date,
'd2|maxdate=s' => \$max_date);

if ($sort eq size) {
} elsif ($sort eq date) {
} elsif ($sort eq frequency) {
} else {

I'm not sure why but it seems that it will only recognise if $sort is size or domain. When I use date or frequency as the options, it just doesn't go into the respective subroutines. Thanks for reading and helping in advance.



Apr 4, 2000, 5:08 PM

Post #2 of 3 (1366 views)
Re: GetOpt doesn't get option!! [In reply to] Can't Post

You should REALLY consider quoting your strings. date() is a Perl function, so saying ($foo eq date) is not the same as ($foo eq "date").


Apr 4, 2000, 6:10 PM

Post #3 of 3 (1366 views)
Re: GetOpt doesn't get option!! [In reply to] Can't Post

Thanks but I've tried that and it still doesn't work. I did this:

if ($sort eq "size") {
} elsif ($sort eq "date") {
} elsif ($sort eq "frequency") {
} else {

what else do you think the problem is because all my subroutines work fine. If I take out &sort_size and replace it with &sort_date, it will work fine. Therefore it is just that my program doesn't recognise it if I put date or frequency for the option.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives