in reply to auto cutting or setting page size limite per lines etc
HTH. HAND.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.
|
|---|