There are other potential issues, but i'm sure you will identify these upon testing.

Don't get me wrong, if this script gives you the desired result then absolutely do use it, but it could be greatly improved. There should be a clear separation between generating the page data and using the page data to generate the html. There is also repetition, which could be reduced using a more sophisticated algorithm and breaking the code up into specialist functions. This would also help in making it more configurable without the risk of it breaking. I would have loved to have shown you the custom written pagination code I use, but its somewhat tied in with my framework and would take considerable effort creating a standalone demo.

Yes another pagination script, the reason is that I don't want to be dependent on JQuery plugins alone, if I get one perl script that works with css for pagination for my library that would be great as ther are so many css pagination styles available on the net !!.

Ok, I modified the script and whats happening now is that upto page 4 it works fine as it prints the counter appropriately but after pager 4 the counter just shows "Prev", "Next" and "Last" I have been trying to trouble shoot it since yesterday without any luck so I am back to your doors again

Upon briefly comparing your Perl version with the PHP version, it looks as though you still have muddled up curly braces and have inadvertently changed the nesting of the conditions. If you indent your Perl version properly then compare with the PHP version, it should be obvious where you have gone wrong (if only you had indented it properly in the first place, it would have saved you debug time!). If you continue to have issues, please post your updated code.

This is another proof that indenting correctly your code is not an option, it is absolutely essential. I have seen so many times bugs due to poor indentation that I would simply not hire someone showing me code not properly indented, because this is a sign of sloppy habits (don't take it as anything personal against you, I realize that you are a beginner, but, really, take now the good habit of properly indenting conditions, loops, functions, etc., you'll save tremendous amounts of time). I am not talking about indentation style (there are several available styles), but about being really consistent in the way of indenting.

And if you come across some poorly indented code (written by someone else, of course), then use a code prettiffier to get it straight even before further looking at it (let alonce chaznging it).