I've created a perl guestbook script. I am attempting to customize it to where only 10 entries show per page and the rest of the entries are shown through page navigation. Like with the Next/Previous links showing 10 entries per page. I can't figure it out tho. Here is my code

Also, please don't use the "date" command to get the date. Every time you use an external command you make your program slower and less portable. The 'strftime' function from the POSIX module is just as simple to use and keeps everything internal to your Perl program.

You should learn how to work around with perldoc, the examples usually are a good help but you can use a module better if you understand what the methods do. Read it carefully, everything you need to know is in it.

Edit: I made it a little more educational. -- Don't reinvent the wheel, use it, abuse it or hack it.

dang i refresh my page and the help is gone . . . so no one is going to help me? . . . so assuming i was just given a page with a module i guess i just have to copy all the codes on that page into my code . . .

It's not that I don't want to help you, but when it's for school I won't give you any code.

That you were given a page with a module means that another programmer did some work for you, it will save you some time and could save you a mistake in your code. You should take a look at it and see how you can implement it into your code. I've seen worse documentation then this one, or documentation I don't understand for I know nothing about the things the module is working with (like Mime::). -- Don't reinvent the wheel, use it, abuse it or hack it.

yea i see what you're saying its just hard cuz i'm a beginner and i am trying to learn. so finding this module in the first place would have been difficult for me and when i got it i didn't understand it anyway thats why i asked about the synopsis on that page cuz i didnt get it so i asked for help.

The Synopsis gives examples of how you might use the code. You need to adapt that code to your specific needs. Reading the rest of the documentation will help you do that.

Data::Page is based round the idea that you have a number of items in an array and that you only want to display a certain number of items from that array on each page. You'll probably also want to have links to the previous and next pages (and perhaps the first and last pages).

So let's assume that you have a list of entries in @entries. You'll need to populate that array yourself. Perhaps it comes from a database. In your case, I think it comes from a text file.

The next thing you'll need to know is which page you want displayed. So let's add a "page" parameter to your CGI program. If no page is given then we'll default to the first page (page 1).

my $page = Data::Page->new; # tell it the total number of entries we have $page->total_entries(scalar @entries); # tell it how many items we want on a page $page->entries_per_page(10); # tell it the current page number $page->current_page($curr_page);

Now the page object can tell us interesting things about the items that should be on the current page. The most interesting will be the indexes into our @entries array of the first and last items on the page. We can use this to display all of the items on this page.

I think you'll find that the page object will return 0 (or maybe "undef") for pages that don't exist. For example, if you're on the first page then there isn't a previous page to go to. So you can use that information to only print those links when they are needed.