in reply to On server, counter file is read-only
If you can read, but not write, the file, it may be a matter of permissions. Make sure that the web server has permission to write to the file. Also, make sure the file path in your script is still correct after the upload.
Update: A few suggestions:
#!/usr/bin/perl use strict ; # ALWAYS ALWAYS ALWAYS use use warnings ; # strict and warnings! Always! use CGI qw/ :standard / ; # Rather than printing the HTML. my $number_of_digits = 6; open( COUNTING, #"< D:/StronyKlientow/cematsil.bptnet.pl/main/Alicja/perl/counte +r.txt" "< ./counter.txt" # For my testing ) or die "can not open file: $!" ; my $count = <COUNTING>; chomp $count ; # You pretty much always want chomp instead of chop. close (COUNTING); $count++ ; open( COUNTING, # ">D:/StronyKlientow/cematsil.bptnet.pl/main/Alicja/perl/counte +r.txt" ">./counter.txt" # For my testing ) or die "Cannot open: $!\n"; print COUNTING $count ; close COUNTING ; my @digits = split( //, $count ) ; my $spline = '%0' . $number_of_digits . 'd' ; $count = sprintf( "$spline", $count ) ; my $image = '' ; my @digitcount = split( //, $count ) ; foreach my $digitimage (@digitcount) { $image .= img( { 'src' => "../obrazki/$digitimage.gif", 'vspace' => 0 } ) ; } print header, start_html( { 'bgcolor' => 'lightblue' } ) ; print table( { 'align' => 'center', 'border' => 0 }, Tr( td( { 'align' => 'center', 'valign' => 'top' }, $image ) ) ) ; print end_html ; exit;
Update 2: Please read Abigail-II's comments below. [s]?he is, of course, absolutely right; the code I posted does nothing to address the case where two people load your page at the same time.
I've only ever actually made one web counter, a couple years ago in Python, so I didn't really think about all the issues. However: I still say, use strict, use warnings, and take advantage of CGI.
YAU: And yes, merlyn has a WebTechniques column on this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: counter
by Abigail-II (Bishop) on Jul 19, 2002 at 10:35 UTC | |
|
Re: Re: counter
by Anonymous Monk on Jul 19, 2002 at 07:04 UTC | |
by DamnDirtyApe (Curate) on Jul 19, 2002 at 07:16 UTC |