Jump to content
xisto Community
Sign in to follow this  
xsize

Perl Programming First, Second, ....

Recommended Posts

My Second Perl Programm

The Simple counter...
u must create the file:
counter.dat

[br]#!/usr/bin/perl[/br]#counter.cgi[br][/br]urldecode{[br] local($val)=@_;[/br] $val=~s/\+/ /g;[br] $val=~s/%([0-9a-hA-H]{2})/pack('C',hex($1))/ge;[/br] return $val[br]}[/br]$dataf:='couner.dat';[br]open(F,"+<$dataf") || die "can't open file counter.dat";[/br]flock(F,$LOCK_EX);[br][/br]@cnt=<F>;[br]$Dat=@cnt[/br]$ip=$ENV('REMOTE_ADDR');[br][/br]($count,$ip)=split(/\s+/,@Dat);[br]$count++;[/br]$Dat=join(' ',$count,$ip);[br]fseek(F,0,0);[/br]print F "$Dat";[br]truncate(F,tell(F));[br][/br]flock(F,$LOCK_UN);[/br]close(F);[br][/br]print "Content-Type: text/html\n\n";[br]print "<HTML><BODY><CENTER><small>";[/br]print "$Dat";[br]print "<\small><\CENTER><\BODY><HTML>";[/br]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.