I can't beleive it can be done in a so few lines!

I though i had to connect to the database table and check if the specific field is present at the table 'counters' but with the eval you give i dont have too....

Unfortunately i didn't understand how the eval() is working here and what the 'undef, $pagename)' is doing after the eval(). Inever used eval before!

Eval is trying to evaluate the statement closed within its parenthesis? Can you explain a bit more if its possible?

The $ stands for the name of the current webpage thst is running? is it with or witout the '.html'? Also because you ask we dont need to know how the current webpage loaded just its name.

in your second statemtn alsoin, the increament $db->do(), you say where pagename = ?, whats the value of ?

$db->do( 'CREATE TABLE counters (pagename text primary key, pagecoun +ter int default 0)' ); eval { $db->do('INSERT INTO counters (pagename, pagecounter) VALUES ($, 0) +', undef, $pagename); }; $db->do('UPDATE counters SET pagecounter = pagecounter + 1 WHERE pagen +ame = ?', undef, $pagename);
Also i forgot to tell you that i also need to print the current webpage's counter to the output after the increment so i need to store it in a variable called $pagecounter.
print table( {class=>'info'}, Tr( td( {class=>'lime'}, a( {href=>'/cgi-bin/show.pl?name=s +howlog'}, h1( {class=>'lime'}, $host )))), Tr( td( {class=>'yellow'}, $display_date)), Tr( td( {class=>'cyan'}, $pagecounter )) );

In reply to Re^6: Making an automatic counter adder for all webpages by Nik
in thread Making an automatic counter adder for all webpages by Nik

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.