SPUG: Trapping Named Anchor References

David Vergin dvergin at bigmindmedia.com
Mon Oct 9 14:03:15 CDT 2000

I need to capture a named anchor reference for a redirect.

Story line:
A user clicks on a saved link or a link in an email like:


but the coolsite.pl script notices the user doesn't have a logged-in cookie so
it displays a log-in page rather than the requested content page. Fine so far.

The user fills in UserID and Password and clicks on Submit. The form action
specifies the log-in script which verifies the users info and then does a
re-direct to the url the user originally wanted to see (which still appears in
its entirety in the browser Location box) to be displayed by the normal display

Everything works fine except the named anchor reference.

Here's the problem: I can find no way to trap the '#item16' portion of the url.
I need that in order to compose the complete URL for the 'Location:' header so
the user does not end up confused to find themselves at the top of a long page
when they really want to see an item farther down.

On Linux/Apache, the anchor ref does not appear anywhere in %ENV

  You can check this at:

Not surprisingly then, I can find no tool in CGI.pm to grab it.

My searches of the likely archives have come up dry.

Lest you suggest integrating the User Verification into the main script, I
should mention that one purpose of the redirect is to avoid the 'Resubmit Form
Data' problem.

My best solution is redundancy: Always dup the anchor ref in the query string.


This allows me to handle any link the user may have saved and to rebuild the
anchor ref from the query string during log-in. It's not exactly normalized but
it does the job. <g>

Any suggestions?

As always, rtfm's, url's, suggested lines of inquiry, wise counsel, key words
for searches: all welcome.

$q=q { $JaPh=~/n[aieuo]c/;$trk="sheelleerr";tr/$@%&*/    /;};
++$i,map{++$i;print,for($q=~/.{$i}(\w| ).{0,$_}/g)}(9,2,4,0);

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/

More information about the spug-list mailing list