in reply to Improving the efficiency of this piece of code

One thing off the top of my head would be to do a:
my $page = param('page');
before the condition tests. That way you only make one call to param.

Mike - mps@discomsys.com

"The two most common elements in the universe are hydrogen... and stupidity."
Harlan Ellison