in reply to auto cutting or setting page size limite per lines etc

The following assumes, of course, that you're getting @link from somewhere before this code executes.

It also assumes each link is already formatted as an anchor or link tag and has the proper HTML formatting around it, but that's easy enough to work into the code.

Finally, it assumes you want your 'next', 'previous', and per-page links links at the top. That can be changed, but it makes the first page a special case if you move it elsewhere.

The current page includes a live link to itself, because it's just easier that way. It also could use modulo to only put a numbered link for every five pages or every ten (or whatever), but it doesn't. This is, after all, just an example. Creating a site that looks more like Google is left as an exercise.
my $links_per_page = 100; ### or any number ### get number of pages ### modulo is your friend my $num_pages = int (( scalar @link ) / $links_per_page); $num_pages++ if @link % $links_per_page; my $page = 0; my $counter = 0; my $file; my $other_pages; ### create per-page links for ( my $i = 1; $i <= $num_pages; $i++ ) { $other_pages .= "<a href='page_$i.html'>$i</a>\n"; } foreach ( @link ) { ### again, modulo is your friend here if ( ( $counter % $links_per_page ) == 0 ) { ### we create a new page here $page++; my $prev = $page - 1; my $next = $page + 1; $file = 'page_' . $page . '.html'; open Fh, "> $file" || die "Can't write to $file: $!\n"; ### header info and such print Fh "<html><head><title>Page $page"; print Fh "</title></head><body>\n"; print Fh "<h1>Page $page of links</h1>\n"; ### we only want a 'previous' link if there's ### a previous page if ( $page > 1 ) { print Fh "<br><a href='page_$prev.html'>"; print Fh "Previous</a>\n"; } print Fh $other_pages; ### we only want a 'next' link if there are ### more pages after this one if ( $page < $num_pages ) { print Fh "<a href='page_$next.html'>"; print Fh "Next</a>"; } print Fh "<br>\n"; } print Fh "$_\n"; ### print a link $counter++; } close Fh; ### The other files got closed when we opened ### new files using the same handle.
HTH. HAND.