in reply to Error 404 fix
That means you'll have to call it slightly differently:sub findurl { my $url; open (INFO, $datafile) or die "Can't open $datafile: $!"; while (<INFO>) { my ($title, $location) = split(/\|/ , $_); if ($title eq $name) { $url = $location; } } close (INFO); return $url; }
I'd try to get rid of the global variables as far as possible, passing $name as an argument to findurl(), and $url as an argument to doit().my $url = findurl(); if (defined $url) { doit(); } else { incomplete(); }
As for general coding advice, you ought to look into using the -w flag and strict. In CGI scripts, you should also use -T for taint checking (see perlsec), and there's usually no good reason not to use CGI instead of your parse subroutine. Yours doesn't handle checkboxes, for example.
Don't worry, these things will help you in the long run.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Error 404 fix
by koacamper (Acolyte) on Sep 30, 2000 at 22:35 UTC |