Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

how to do perldoc links with special characters

by Lotus1 (Curate)
on Apr 20, 2013 at 16:32 UTC ( #1029658=monkdiscuss: print w/replies, xml ) Need Help??

When I use perlmonks shortcuts to the perldocs it goes to the page but not down to the anchor location on the page like the full link does. The apostrophe and the percent symbol are being replaced with things like '%27' and '%25'.

If I link with the full url like this it works.'s--i-option-from-within-a-program%3f

However, this goes to the page but not the anchor. The text below shows what I have in the link at the word 'this'.


Update: Interesting; the full link doesn't go to the anchor with an actual question mark in it.'s--i-option-from-within-a-program?

Replies are listed 'Best First'.
Re: how to do perldoc links with special characters
by LanX (Chancellor) on Apr 20, 2013 at 16:42 UTC
    This works cause I translated the '?' back.


    Don't know if there is any ambiguity, otherwise I would pray to the gods humbly asking for a fix! =)

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      This works cause I translated the '?' back.

      Actually it doesn't. It still goes to the page but not the anchor.

      Update: I am using IE8 but I went ahead and tested your link on Chrome. So the '?' part is solved but the question of the apostrophe remains.

        Well works for me in FF!

        Which browser do you use?

        Maybe it's a FF DWIM feature. I'm too lazy to look up the specs now...

        Cheers Rolf

        ( addicted to the Perl Programming Language)

        That link works for me using firefox 20 on Linux. Maybe a browser/OS thing ?

Re: how to do perldoc links with special characters (perlmonks
by Anonymous Monk on Apr 20, 2013 at 17:02 UTC
     [doc://perlfaq5#How-can-I-use-Perl's--i-option-from-within-a-program?] How can I use Perl's i option from within a program?
    die fudge(q{ +7s--i-option-from-within-a-program%3f}); sub fudge { local $_ = shift ; return $_ if not m{\Q\E|\Qdoc://\E}si; # d +on't deal return $_ if m{\Q\E}si; # don't deal s/^\[//; s/\]$//; my $right = ""; s{\|(.*)}{} and $right.= $1; s{^\Qhref://\E}{}si; s{^\Q\E}{}si; s{^\Qdoc://\E}{}si; s{\Q.html\E}{}si; my( $left, $anchor ) = split '#', $_, 2; $left =~ s{/}{::}g; if( m{%[a-zA-Z0-9]{2}}si ){ $_ = unescape( $anchor ) ; s/ /-/; $anchor = $_; } if( $anchor ){ $anchor =~ s{\[}{%5b}g; $anchor =~ s{\]}{%5d}g; $left .= '#' . $anchor ; } if( length $right ){ $right =~ s{\[}{[}g; $right =~ s{\]}{]}g; return "[doc://$left|$right]" ; } return "[doc://$left]"; } sub Main { for my $file ( ( glob 'perlfaq*.html' ), (glob 'perlpod*html' ), ( +'perlintro.html', 'perlop.html') ){ ( my $name = $file ) =~ s/\.html//; #~ dd [ $file => $name ]; my $tree = HTML::TreeBuilder->new; $tree->parse_file( $file ); $tree->look_down( _tag => "a", name => qr/./, sub { my $question = $_[0]->attr('name'); return if $question =~ m{ ^\s* (?: AUTHOR.AND.COPYRIGHT | NAME | DESCRIPTION | CREDITS | THE.QUESTIONS | TABLE.OF.CONTENTS ) \s*$}xs; print fudge("[doc://$name#$question]"), "\n"; 0; }, ); } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://1029658]
Approved by LanX
[choroba]: but undef %hash and %hash = () both work, too, but the first one keeps the memory allocated, while the latter makes it available for other parts of the program.
[choroba]: iirc
[perldigious]: karlgoethebier: Well it is a pretty old and complicated (for me) bit of code I wrote (poorly by my current standards), so I'm expecting everything to break when I add the scoping and find out what else is undesireably scope changed. :-)
[perldigious]: Ah, thanks choroba, that sort of thing was precisely what I was wondering when I asked.
[perldigious]: I didn't want to tie up memory unecessarily basically, I wanted to "delete" it specifically to free it up, and wasn't sure I was even accomplishing that.
[stevieb]: perldigious You should start by writing some unit tests. That'll ensure current functionality doesn't break with changes.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2017-07-21 19:55 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (335 votes). Check out past polls.