Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: how to do perldoc links with special characters (perlmonks faq2doclink.pl)

by Anonymous Monk
on Apr 20, 2013 at 17:02 UTC ( [id://1029664]=note: print w/replies, xml ) Need Help??


in reply to how to do perldoc links with special characters

 [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{http://perldoc.perl.org/perlfaq5.html#How-can-I-use-Perl%2 +7s--i-option-from-within-a-program%3f}); sub fudge { local $_ = shift ; return $_ if not m{\Qhttp://perldoc.perl.org/\E|\Qdoc://\E}si; # d +on't deal return $_ if m{\Qhttp://perldoc.perl.org/5.\E}si; # don't deal s/^\[//; s/\]$//; my $right = ""; s{\|(.*)}{} and $right.= $1; s{^\Qhref://\E}{}si; s{^\Qhttp://perldoc.perl.org/\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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1029664]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-03-28 17:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found