Re: paging page trouble
- From: nobull@xxxxxxxx
- Date: 25 Jul 2005 06:04:54 -0700
samwyse wrote:
> Alexandre Jaquet > wrote:
> > local our $nb_page = arrondi ($total / 4, 1);
> > local our $min_index = $query->param("min_index") || '0';
> > local our $max_index = $query->param("max_index") || '4';
> > local our $page_nbr = $query->param("pagenbr") ;
> > local our $page_start = $query->param("page_start") || '0';;
> > local our $page_end = $query->param("page_end") || '4';;
> my $nb_page = arrondi ($total / ITEMSPERPAGE, 1);
> my $page_nbr = $query->param('pagenbr');
> my $page_start = max(0, $page_nbr - PAGESPAN )
> my $page_end = min(nb_page, $page_nbr + PAGESPAN )
> my $min_index = ITEMSPERPAGE * $page_nbr;
> my $max_index = $min_index + ITEMSPERPAGE - 1;
>
> BTW, why the 'local our' in your code? Is that your own convention, or
> just something I've not seen before?
Lexicals that are declared at file scope and then used within
subroutines in CGI scripts that are to (potentially) be be run under
mod_perl "will not remained shared".
For this reason such variables should be made into local()ized package
variable.
Note: from a programming purist point of view (as in "global variables
are bad") file-scoped lexicals are already global variables, and making
them package-scoped does not make them any more ugly.
It is probably a good idea to try to write code without so many global
vaiables.
.
- References:
- Re: paging page trouble
- From: samwyse
- Re: paging page trouble
- Prev by Date: Re: posting an array
- Next by Date: Re: Prepending to a file
- Previous by thread: Re: paging page trouble
- Next by thread: Re: paging page trouble
- Index(es):
Relevant Pages
|