Hello i have made i perl module called MyCounter.pl which is supposed to add +1 to every page counter depending on the perl page that calls the module.
Thai is the following code:
package MyCounter;
use strict;
use Exporter 'import';
our @EXPORT = qw/counter/; # functions to export by default
sub counter
{
my ($pagename, $db, $host) = @_;
($pagename) = ($pagename =~ m{([^/\\]+?)(?:\.[^/\\.]+)?$});
#======= Insert or Update pagecounter appropriately, then display i
+t ========
eval { # Just ignore errors if the record already exists
$db->do('INSERT INTO counters (pagename, pagecounter) VALUES (?,
+ 0)', undef, $pagename);
};
$db->do('UPDATE counters SET pagecounter = pagecounter + 1 WHERE pa
+gename = ?', undef, $pagename) unless( $host eq 'webmaster' );
my ($counter) = $db->selectrow_array('SELECT pagecounter FROM count
+ers WHERE pagename = ?', undef, $pagename);
return $counter;
}
1;
and it works fine within perl because i have every perl script of mine that needs counting to call my perl module.
for example from my index.pl i use
use MyCounter; #i declare the usage of MyCounter
....
....
$counter = counter( $0, $db, $host ); #i call my module
Now the problem is how IF i can do the same thing, that is call the handmade perl module within from my every php script that need counting.
So please enlight me if this thing can happen and how to call it.
All i want to do after the calling of the perl module is to print the counter for the specific page, thats all!