Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Perl counter in cgi-bin

by Mr. Muskrat (Canon)
on Jun 05, 2004 at 15:50 UTC ( #361622=note: print w/replies, xml ) Need Help??

in reply to Perl counter in cgi-bin

You are not testing whether the open statements worked before continuing on.

Also, what is the point of the for loop? A simple print $data; should suffice since the numbers will all appear on one line once the funky stuff is removed (since you are not printing a <br />). The funky stuff that I mentioned are the curly braces and they are killing the script.

Here's your for loop with the curly braces removed (and a couple mys for good measure):

for ( my $count = 0; $count < length( $data ); $count++ ) { my $number = substr( $data, $count, 1 ); print( $number, "\n" ); }

Here is another way to do that loop (bonus! I added the <br />s):

for my $number (split //, $data) { print "$number<br />\n"; }

Someone is bound to say this if I don't.... You can even do it with a one-liner:

print "$_<br />\n" for (split //, $data);


Update: Rewrote the last sentence in the second paragraph for clarity.

Replies are listed 'Best First'.
Re^2: Perl counter in cgi-bin
by edeita2 (Novice) on Jun 05, 2004 at 20:05 UTC
    Dear friend, I have tried your solution, but still the same error "an error occurred while processing this directive" I think I have to find that directive first and correct or change then try the code, I`m gonna look at Apache conf. file god bless
      I didn't look at your code...You didn't mention anything about file permissions. Just in case you missed that part out, 'counter.dat' should be chmod'ed to 666 and your perl script to 755.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://361622]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2023-09-22 17:42 GMT
Find Nodes?
    Voting Booth?

    No recent polls found