I have just a few comments and questions:
At the beginning of the file, you do this:
my $oldpage = <DATA>;
And it works every time. When the web pages are downloaded from perlmonks and saved, there are no \n's. When you go to slurp the line of DATA, it returns the web page, because it is only a single line. The only concern I have with this is it relies on vroom not having put \n's on the web page display. If the structure of the web page changes, the code could break.
Perhaps a slightly better way to do it would be to slurp in every bit of DATA, using something similar to:
read DATA, my $oldpage, -s DATA;
This isn't prone to the same problems as the previous line of code.
Most of the program is wrapped in curly braces that don't seem to be necessary. Is there a particular reason that it is here, or are they remnants from your original development code?
Also, the following snippet will fast forward to just after the __DATA__ tag, and append the new web page information, all using only a single open call:
open SELF, "+< $0" or die "Can't open $0: $!";
local $/ = join '', $/, '__DATA__';
<SELF>; #fast forward to the good stuff
truncate SELF, tell SELF;
print SELF $/, $newpage;
Just thought you'd like to see this neat trick...
Update: Added in the line to truncate the file to the current position. It is safer than just blindly printing.
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link
or How to display code and escape characters
are good places to start.