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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



daniel_lsl
Deleted

Apr 4, 2000, 4:51 PM

Post #1 of 3 (585 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) {
&sort_size;
} elsif ($sort eq date) {
&sort_date;
} elsif ($sort eq frequency) {
&sort_frequency;
} else {
&sort_domain;
}

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.

Regards,
Daniel


japhy
Enthusiast

Apr 4, 2000, 5:08 PM

Post #2 of 3 (585 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").


daniel_lsl
Deleted

Apr 4, 2000, 6:10 PM

Post #3 of 3 (585 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") {
&sort_size;
} elsif ($sort eq "date") {
&sort_date;
} elsif ($sort eq "frequency") {
&sort_frequency;
} else {
&sort_domain;
}

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