笔记 by 车东

给phpMan加上perldoc -f / -q模式

· 技术笔记|Tech Notes

📌 TLDR

给 phpMan 加上 perldoc -f / -q 模式:-f 用来查 Perl 内置函数、-q 查常见问题,这样在网页上就能像 man 一样查 Perl 文档;文末附了作者与上游的往来邮件和实现方式。

java - phpMan

perldoc -f 用于搜perl内置的函数 perldoc -q 用于在perldoc中进行标题的全文检索

Marcin Gryszkalis 写道:

Hi

I like you script and I added little fix to make it try additional perldoc forms (with -f and -q switch). I know that funciotns are available at perlfunc page (and faqs at perlfaqX) but perlfun is pretty big page so it takes some time to render (and you still have tearch in the page for specific function). The fix chenges getPerldocPage to something like (It assumes that perldoc returns nonzero value when nothing’s found - it seems to be true in all systems I tested).

function getPerldocPage ($parameter) { exec(“perldoc “.escapeshellarg($parameter), $lines, $returncode); if ($returncode == 0) return formatManPerlDoc($lines, “perldoc”); exec(“perldoc -f “.escapeshellarg($parameter), $lines, $returncode); if ($returncode == 0) return formatManPerlDoc($lines, “perldoc”); exec(“perldoc -q “.escapeshellarg($parameter), $lines, $returncode); if ($returncode == 0) return formatManPerlDoc($lines, “perldoc”); return “”; }

regards