++ the comments above. Just to add though, $cb is a "callback." Callbacks are great mechanisms for adding your "specialized" code into a generic framework. In this particular case, your cb subroutine will be called as links are found during the parsing of the "index.html". You see
quite a bit of use of the callback approach in parsing style
modules (XML, HTML, etc), gui modules (Tk, Gtk, etc), dispatch tables, and signal handlers. Page
53 of
Advanced Perl Programming has a pretty good definition of callbacks:
A callback function is an ordinary subroutine whose reference is passed around. The caller (who uses that function) doesn't neccessarily have an idea of which subroutine is getting invoked.
-derby
update: darn that jeffa. I think perlmonks needs an "oops I'm too slow" button.
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.