Dear monks,
I've come to this point where it's high time I wrote some documentation for the couple of files I've written so far. I was thinking of using a tool very much like
Javadoc so I set myself to writing one up, in a rather simple way where it'd take a .pl file, detect the subs, keep the sub names and add them to the HTML file...
I wanted to take a line, eg
sub myFunction # this function does blablabla and solely retrieve the first part, from sub till #... I wrote the following expression which can probably be simplified :
if ($content =~ /^(sub\s+\w+).+$/)
{
print "$1.\n"; # print sub name
if ($content =~ /(#.+)$/)
{
print "$1\n"; # print sub comment
}
}
How can I reduce the 2 ifs to a one-liner ? Thanks for your insight...
But then again, I assume a perl2html parser already exists, so could someone please tell me if there's such a package somewhere ?
Thanks all
20030827 Edit by jeffa: Changed title from 'regular expression help '
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.