First of all, learn to use use strict;, and how to return values from your subroutines. All this global data flying around will hurt you again and again, especially without use strict;.

And my god, you are parsing the CGI stuff yourself. Big no no. Use the CGI module (see perldoc CGI).

As for your problem: why not set $url to a standard location containing your error message in findurl() before entering the loop over your data:

sub findurl { open (INFO, "$datafile"); @information = <INFO>; $url = "http://mysite/error_message.html"; foreach $information (@information) { ($title, $location) = split(/\|/ , $information); { if ($title eq $name) { $url = $location; } } } close (INFO); }

And please, Fellow Clueful Monks, do not kill me for giving an answer to a request like this.

And for you poor soul that asked this question: get a decent book on Perl programming, quick, quick, run to the next bookstore, don't walk, and buy "Learning Perl" or something similar. See Tom Christiansen's book review list for other book suggestions. No no, don't tell me you can't afford that (if that is really the case, start with perldoc perlfaq and read through the online-docs). May the spirit finally come upon you.

Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com


In reply to Re: Error 404 fix by clemburg
in thread Error 404 fix by koacamper

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.