in reply to Re^2: Undefined Value Error Message
in thread Undefined Value Error Message
The cases of '"my" variable … masks earlier declaration' will probably mess things up."my" variable $LastName masks earlier declaration in same scope at 107 +8385 line 32. Variable "$result_count" will not stay shared at 1078385 line 63. "my" variable $LastName masks earlier declaration in same scope at 107 +8385 line 78. "my" variable $pagesize masks earlier declaration in same scope at 107 +8385 line 124. Unrecognized escape \s passed through at 1078385 line 133. Variable "$pagecount" will not stay shared at 1078385 line 136. Unrecognized escape \s passed through at 1078385 line 140. Unrecognized escape \s passed through at 1078385 line 152. 1078385 syntax OK
The "unrecognized escapes" are cases where you seem to have an unnecessary backslash (or maybe you intended to put \" but didn't?)
The variables that "will not stay shared" happen because you're defining the "search" sub inside the scope of defining the "count" sub, the variables in question are declared (lexically scoped) inside "count", before sub search begins, and then they're being used inside "search".
That's a strange (and wrong) way to lay out subroutines. For example, consider what happens at start-up if the "reqpage" parameter you get is greater than 1: the "search" sub will be called without the "count" sub being called first, but the "$result_count" variable is only assigned a value (from a query) in the "search" "count" sub, which hasn't been called in this case. That would probably explain the problem you're describing.
There's also a missing double-quote at line 111 (the over-long line in the "heredoc"; this doesn't affect compiling, but it'll screw up your page display. (I noticed that because I used emacs with colorized text, and after that line, the coloring was inverted for code vs. string values).
So let me suggest:
- FIX YOUR INDENTATION so that it is consistent with the actual structure of the code.
- Move all of sub search { … } so it's completely outside of sub count { … }
- Figure out how the "unshared" variables in "search" (which are now undeclared) are going to be assigned the values that they're supposed to have when the script runs with reqpage > 1
- Maybe google around for "paging database query results in perl cgi" - I think it should be pretty easy to find some useful examples to work from.
(Updated to get the sub names right in the middle paragraph, and a grammar blot in the suggestion list.)
|
---|