Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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; close SELF;

    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.

In reply to (dkubb) Re: (2) Voting Booth Nodelet Watcher by dkubb
in thread Voting Booth Nodelet Watcher by jcwren

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":

  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    Domain Nodelet?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others meditating upon the Monastery: (2)
    As of 2024-07-21 01:04 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found

      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.