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

Wow! That worked :-)

Changed for $i (@pages) to for my $i (@pages) and that did the trick.

You rock!! :-)
Thanks so much,

-Bob

  • Comment on Re^2: using pagecount variable in array?

Replies are listed 'Best First'.
Re^3: using pagecount variable in array?
by davido (Cardinal) on Jul 23, 2006 at 16:17 UTC

    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

          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$..$/
      > "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
Re^3: using pagecount variable in array?
by mrborisguy (Hermit) on Jul 23, 2006 at 15:29 UTC

    Did you also change the top of your script to include use strict;? I think that was much of the point of liverpole's post.

        -Bryan

      > Did you also change the top of your script to include use strict;?

      No, I already was using strict:

      #! /usr/bin/perl -w use strict; use POSIX; use DBI; use CGI qw(:standard); my ($dbh, $sth, $count);
      Thanks,

      -Bob