Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Anchor Tag and Perl

by Anonymous Monk
on Feb 13, 2009 at 20:05 UTC ( #743676=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!

I have a bug here where in my Perl script a have a link like:
<a name="main_name" href="$tr&more=name#main_name\">

The problem here is that the "#" at the end of the url; where I need it in here to go to the location on the page I want after clinking on this link ( anchor tag) is ignoring the other values I am passing to the script, so my logic is going no where? Has anyone seeing this bug/problem before, any help?
Thanks a lot!

Replies are listed 'Best First'.
Re: Anchor Tag and Perl
by Corion (Pope) on Feb 13, 2009 at 20:33 UTC

    If you want a # sign in a CGI parameter value, you have to escape it.

    If you want a # sign in the path, you have to escape it.

    If you expect the stuff after a # sign to be available to your script, that's not how URLs work.

      This article on Fragment identifiers may help explain why it's not doing what the OP wants.

      The fragment identifier functions differently than the rest of the URI: namely, its processing is exclusively client-side with no participation from the server. When an agent (such as a Web browser) requests a resource from a Web server, the agent sends the URI to the server, but does not send the fragment. Instead, the agent waits for the server to send the resource, and then the agent processes the resource according to the fragment value. In the most common case, the agent scrolls a Web page down to the anchor element which has an attribute string equal to the fragment value.
Re: Anchor Tag and Perl
by kennethk (Abbot) on Feb 13, 2009 at 20:09 UTC
    Please read How (Not) To Ask A Question. What is your code supposed to do? What modules are you using? 1 line of code is worth 1k words.
      I think people around here has a problem understanding other people, what the person is asking is how to pass the value from some Perl script where this is to the same script, look at the parameters he is trying to pass in the link, where this link has to go ta a specific location on a page, after the script reads the values passed on the header, but the anchor tag that is not working because of "#" at the end of the url, think.
Re: Anchor Tag and Perl
by Your Mother (Chancellor) on Feb 13, 2009 at 20:10 UTC

    This is the well known line 42 issue. You can usually fix it by commenting out line 42 in your code. If that doesn't work you could try asking an intelligible question.

Re: Anchor Tag and Perl
by Lawliet (Curate) on Feb 13, 2009 at 20:31 UTC

    Backslash it?

    And you didn't even know bears could type.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://743676]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2017-12-12 06:08 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (326 votes). Check out past polls.