in reply to Re^2: using pagecount variable in array?
in thread using pagecount variable in array?

You're mistaking the cause for your error. In fact, the code you posted will run AS-IS if you simply assign a value to $total_recs at the start of the script, and use POSIX qw/ceil/;. Though it's wise beyond words to learn to use strict;, and smart to use lexical variables such as my $i, the change you made by adding my $i to your foreach loop can't be what fixed the code you posted. The code you posted essentially works.

So what exactly was the error you were getting?


Dave

Replies are listed 'Best First'.
Re^4: using pagecount variable in array?
by liverpole (Monsignor) on Jul 23, 2006 at 17:43 UTC
        I think that [using "strict"] was much of the point of liverpole's post.

    Yes, that and the fact that we can't know what output a user is "expecting" to get, especially when the output we get is as it should be.

    And as davido points out, the OP's code "essentially works".  So, although it's nice and gratifying that your problem is solved, bobafifi, we're still all scratching our heads here, wondering:  "what was failing for you in the first place?"


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
Re^4: using pagecount variable in array?
by bobafifi (Beadle) on Jul 23, 2006 at 17:56 UTC
    > "what was failing for you in the first place?"

    I was getting "Internal Server Error" pages:

    Internal Server Error The server encountered an internal error or misconfiguration and was u +nable to complete your request. <snip>
    As soon as I changed for $i (@pages) to for my $i (@pages), the script worked.

    Thanks again,

    -Bob

      Of course: Perl threw you an error saying --as per use strict-- Global symbol "$i" requires explicit package name at ... and that unexpected error message played havoc with the headers of your HTML-page.

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      use CGI::Carp qw/fatalsToBrowser/;
      in future while developing your CGI scripts :) It will protect you from many mysterious problems ;)

           s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print
        But only use it on the development server and not on the production site as you never know what data might be exposed by an unexpected error. It would not be too good for the world to see your passwords and logins on the Internet!

        CountZero

        "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law