If you use CGI.pm, then there's no need to get messy with regexps: the param and (self_)url function/methods are all you need ...

use CGI qw/ :standard /; print header; # save requested slice my $slice = param( 'slice' ); # generate URLs to next 3 slices for my $offset ( 1..3 ) { param( 'slice', $slice + $offset ); print a( { -href => self_url }, query_string ); } # restore original (if needed) param( 'slice', $slice ); __END__ Query: slice=31&this=that Output: slice=32&this=that slice=33&this=that slice=34&this=that Query: this=that&slice=49&that=this Output: this=that&slice=50&that=this this=that&slice=51&that=this this=that&slice=52&that=this Query: this=that&that=this&slice=5 Output: this=that&that=this&slice=6 this=that&that=this&slice=7 this=that&that=this&slice=8

Season with input validation/error handling to taste. :)

    --k.


In reply to Re: Need to create a pre and post string from a REQUEST_URI by Kanji
in thread Need to create a pre and post string from a REQUEST_URI by S_Shrum

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.