Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Perlmonks Code Proxyby Ovid (Cardinal) |
on Aug 19, 2000 at 00:22 UTC ( [id://28583]=perlquestion: print w/replies, xml ) | Need Help?? |
Ovid has asked for the wisdom of the Perl Monks concerning the following question:
If I want to copy some code from Perlmonks, I find that I cannot cut and paste directly from the Web page without losing formatting. What I usually do is view source, copy the code to a file, and run a script I wrote that converts that HTML into proper Perl code. What I would prefer, however, is to have a "Download this code" link after code snippets that are properly posted with <CODE></CODE> tags.
Since this feature is not available (or if it is, I'm not aware of it), I thought it would make a nice project to write a script that would do this for me. I don't know much about proxy servers or Web automation, so this is a learning experience for me. The following is the first stab at the code (kind of a "proof of concept"). All this code is supposed to do is display a Web page with a (currently) non-functional download link after each CODE posting. Also, all HREF links are pointed back to this code. The problem lies in the regex and the while loop that it is in. When I run the code, it simply hangs. While running it through a debugger, it seems to identify matches in a random, non-sequential order, thus not permitting the while loop to end. I know this is probably something ridiculously simple that I have missed, but I am pulling my hair out over this. Any help would be appreciated.
Cheers, Incidentally, some of the regexes and code above work only because of the layout of Perlmonks. This should not be viewed as any sort of general purpose script.
Back to
Seekers of Perl Wisdom
|
|