Hello Jesse Smith,

Another point: Please note that it is both simpler and safer to avoid code duplication whenever possible:

my $db_name = $DATABASE2; my $suffix = 'NO HTTP_REFERRER'; if (defined $ENV{'HTTP_REFERRER'} && length $ENV{'HTTP_REFERRER'} > 0) { $db_name = $database; $suffix = "<A HREF=\"$ENV{'HTTP_REFERRER'}\">$ENV{'HTTP_REFERRER'} +</a>"; } $shortdate = `date +"%D %T %Z"`; chomp $shortdate; open(my $db, '>>', $db_name) or die "Cannot open database '$db_name' f +or appending: $!"; print $db "$ENV{'REMOTE_ADDR'} - $shortdate - $ENV{'HTTP_USER_AGENT'} +- " . "<A HREF=\"http://$ENV{'HTTP_HOST'}$ENV{'REQUEST_URI'}\">htt +p://$ENV{'HTTP_HOST'}$ENV{'REQUEST_URI'}</a> - $suffix\n"; close($db) or die "Cannot close database '$db_name': $!";

(Code untested, and with suggested improvements included: chomp instead of chop, the 3-argument form of open, a lexical filehandle, and testing for file open and close errors.)

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re: if statement based on HTTP_REFERRER by Athanasius
in thread if statement based on HTTP_REFERER by Jesse Smith

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.