in reply to Re: Drop Down Selection #2
in thread Drop Down Selection #2

Ant, Thank you for your response to my question. I am still fairly new to CGI scripting, which is why I need to ask the following question: How should the script look with the push added? I've tried multiple ways of inserting the push but I keep getting a 500-Internal Error. I understand this completely:
print $query->popup_menu(-name=>'userid', -values=>\@users);
But the part that has me stiffled, is this:
# open the text database unless(open(PFD,$db)) { &printError("Could not open user database"); exit(1); } # first check if user exist $path=''; while (<PFD>) { chomp; ($u,$p,$path)=split('\|',$_);###$u loop?? how? if ($userid eq $u) { $rc=1; last; } } close(PFD);
Thank you so much

Replies are listed 'Best First'.
Re: Re: Re: Drop Down Selection #2
by suaveant (Parson) on May 09, 2001 at 06:25 UTC
    # open the text database unless(open(PFD,$db)) { &printError("Could not open user database"); exit(1); } my @users; # first check if user exist $path=''; while (<PFD>) { chomp; ($u,$p,$path)=split('\|',$_);###$u loop?? how? push @users, $u; if ($userid eq $u) { $rc=1; last; } } close(PFD); print $query->popup_menu(-name=>'userid', -values=>\@users);
    That should work, but in your code you do a last if $userid eq $u, which means @users will store all the users in the list until the one that matches $userid... not sure if that is what you want.
                    - Ant
      The presence of an error check is less valuable than the presence of an error check that captures all relevant status information.

      As perlstyle says, including the name of the file you are trying to open and the contents of $! is a substantive style issue. That information is valuable, and when things go wrong you want to have it from the start.

      Thank you very much! That did the trick! I have been working on this for far too long! I sincerely appreciate your assistance.