![]() Back to www.deitel.com |
1 #!C:\Perl\bin\perl
|
2 # Fig. 25.15: fig25_15.pl
|
3 # Program to track the number of times
|
4 # a Web page has been accessed.
|
5
|
6 use CGI qw( :standard );
|
7
|
8 open( COUNTREAD, "counter.dat" );
|
9 $data = <COUNTREAD>;
|
10 $data++;
|
11 close( COUNTREAD );
|
12
|
13 open( COUNTWRITE, ">counter.dat" );
|
14 print( COUNTWRITE $data );
|
15 close( COUNTWRITE );
|
16
|
17 print( header(), "<div style = \"text-align: center;
|
18 font-weight: bold\">" );
|
19 print( "You are visitor number", br() );
|
20
|
21 for ( $count = 0; $count < length( $data ); $count++ ) {
|
22 $number = substr( $data, $count, 1 );
|
23 print( img( { src => "images/$number.gif" } ), "\n" );
|
24 }
|
25
|
26 print( "</div>" );
|