• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

what would this be in perl ?

GregT

Waffles!!
NLC
how would i do this

<?php
$filename= "hits.txt" ;
$fd = fopen ($filename , "r") or die ("Uhoh! The PHP script cant open $filename") ;
$fstring = fread ($fd , filesize ($filename)) ;
echo "$fstring" ;
fclose($fd) ;

$fd = fopen ($filename , "w") or die ("Uhoh! The PHP script cant open $filename") ;
$fcounted = $fstring + 1 ;
$fout= fwrite ($fd , $fcounted ) ;
fclose($fd) ;
?>

in perl ? this is one of the first times im using perl for a web scripting language, i've been using it for other cmd line things, so bear with me :classic2:
 
Code:
#!perl

print 'Content-type: text/html'."\n\n";

$filename='hits.txt';
open(FD,'<'.$filename) or die 'Uhoh! The Perl script can\\'t open '.$filename;
$fstring=<FD>;
print $fstring;
close(FD);

open(FD,'>'.$filename) or die 'Uhoh! The Perl script can\\'t open '.$filename;
$fcounted=$fstring+1;
print FD $fcounted;
close(FD);
 
Back
Top