Thank you Monks.

I have made the suggested changes, but I haven't fixed all the problems. Now I get everything open, but on the server I get a software error with no information as to what the error is. On the CLI I get no error, but the output stops as soon as the script gets into the "if(exists ($allIPs{$userIP}))" loop, it prints the first line, and nothing else. The nested loop just doesn't seem to be activated at all. Any suggestions?

~~Guildencrantz
#!/usr/bin/perl -wT # # Script: Dynamic Dungeon Siege IP Database Activate IP Script # Author: Guildencrantz # Version: 4-13-02 # use strict; use DB_File; use CGI; use CGI::Carp 'fatalsToBrowser'; my $q = new CGI; my $userIP = $q->remote_host; my $allIPsPath = "/var/www/cgi-bin/ds/database/allIPs.db"; my $activeIPsPath = "/var/www/cgi-bin/ds/database/activeIPs.db"; tie my %allIPs, "DB_File", $allIPsPath or die "Cannot open allIPs database: $!"; tie my %activeIPs, "DB_File", $activeIPsPath or die "Cannot open activeIPs database: $!"; print "userIP = $userIP\n"; print "userdata = $allIPs{$userIP}\n"; if( exists $allIPs{$userIP} ) { print "exists in allIPs\n"; if( exists $activeIPs{$userIP} ) { print "exists in activeIPs\n"; print "Content-type: html/text"; print <<END_OF_BLOCK; <HTML> <HEAD> <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/ds +-cgi/viewActive.pl"> <TITLE>ACTIVE</TITLE> </HEAD> <BODY> <H1>Your IP is already marked as active!</H1> <P> <A HREF="/ds-cgi/viewActive.pl"> You will be forwarded in 5 seconds </A> </P> </BODY> </HTML> END_OF_BLOCK } else { print "does not exist in activeIPs\n"; $activeIPs{$userIP} = $allIPs{$userIP}; print "active IPs= $activeIPs{$userIP}\n"; print "Content-type: html/text"; print <<END_OF_BLOCK; <HTML> <HEAD> <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/ds +-cgi/viewActive.pl"> <TITLE>Added!</TITLE> </HEAD> <BODY> <H1>Your IP has been activated!</H1> <P> <A HREF="/ds-cgi/viewActive.pl"> You will be forwarded in 5 seconds </A> </P> </BODY> </HTML> END_OF_BLOCK } } else { print "Content-type: text/html\n\n"; print <<END_OF_BLOCK; <HEAD> <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/ds/submit. +html"> <TITLE>IP Not Registered</TITLE> </HEAD> <BODY> <H1>There is no entry in the database for this IP. You must regis +ter this IP and the associated server attributes</H1> <P> <A HREF="/ds/submit.html"> You will be forwarded in 5 seconds </A> </P> </BODY> </HTML> END_OF_BLOCK } untie %activeIPs; untie %allIPs;

In reply to Re: Exists with DBM by Guildencrantz
in thread Exists with DBM by Guildencrantz

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.