I have two questions for any not-busy perl monks tonight, if you can help with either one I'd be very much appreciated. Firstly, I have had problems time and time again with databases over writing themselves and each time it's a different problem so if I get an old script to work it has nothing to do with why this one won't. Can someone take a quick look below and see if you can see why only the last value attempted is saved into the db? (database variable is $emails('$email') = " ")
#!/usr/bin/perl -w open( STDERR, ">>/home/sulfericacid/public_html/test/error.log" ) or die "Cannot open error log, weird...an error opening an error log +: $!"; use CGI::Carp 'fatalsToBrowser'; use strict; use warnings; use POSIX; use CGI qw/:standard/; # INIT { $| = 1 } require SDBM_File; my %emails; my $list = "list.dbm"; my $adminmail = 'admin@test.com'; my $sendmail = "/usr/lib/sendmail"; print header, start_html('Email Management'); print start_form(), table( Tr( td("Email: "), td( textfield( -name => 'email', -size => 40 ) ) ), Tr( td(), td(submit) ), ), end_form(), hr(); if ( param() ) { my $email = param('email'); if ( param('email') ne "" ) { tie %emails, 'SDBM_File', $list, O_CREAT | O_RDWR, 0644; if ( !tied %emails ) { warn("database unsuccessful $!.\n"); } $emails{$email} = " "; print "Email address added to database!"; foreach ( sort keys(%emails) ) { print "$_ => $emails{$_}<br>"; } } else { print "Where is the email?\n"; } } print end_html();
Now I have a question, please don't give me any codes...I just need ideas on how to do this. I have a counter I made a while back but I want to track $totalhits, $hitstoday, $weekhits. How could I go about setting it up so it logs total hits, hits done today and hits done this week? I've never worked with time scripts so I'm pretty clueless. Any guidance (but NO codes please, I want to write this myself) would be so appreciated!

Thanks everyone

"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid


In reply to DB Ovewriting (again..)/ Counter Question by sulfericacid

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.