Here is a small program that extracts all the list-items from the HTML:
use Modern::Perl; use HTML::PullParser; use Data::Dump qw/dump/; my $document_to_parse = 'html_1.html'; my $p = HTML::PullParser->new( file => $document_to_parse, start => '"S", tagname, text', end => '"E", tagname, text', text => '"T", text', ) or die "Error: $!"; my @data; my $text = ''; while ( my $token = $p->get_token ) { if ( ( $token->[0] eq 'S' and $token->[1] eq 'ul' ) .. ( $token->[0] eq 'E' and $token->[1] eq 'ul' ) ) { if ( $token->[0] eq 'T' ) { $token->[1] =~ s/(\s*)$//g; $text .= "$token->[1] " if $token->[1]; } if ( ( $token->[0] eq 'S' and $token->[1] eq 'li' ) or ( $token->[0] eq 'E' and $token->[1] eq 'ul' ) ) { $text =~ s/(\s*)$//g; push @data, $text if $text; $text = ''; } } } say dump(@data);
It returns the following from the first HTML:
2 MB Fast RAM expansion connects to the 40 pin expansion header of the Commodore A570 four 1M×4 chips soldered on board disable jumper nothing else is required to be on the board as the multiplexing circui +t is already in the A570 Photo front side
And for the second HTML:
processor 68EC030 @ 40 MHz or 68030 @ 33 / 50 MHz, PGA optional 68882 PGA FPU memory one 72 pin SIMM socket accepts 32 MB RAM supports 4, 8, 16, 32 MB SIMMs, 60-70 ns burst RAM access optional modules SCSI controller NCR 53C80 controller IC does not use DMA transfer autoboot ROM (csascsi.device) DB25 external SCSI connector supported by NetBSD and OpenBSD Photo front side back side Software Twelve_Gauge_U62.bin (32 kB) firmware v1.0 22162A / R1.0 / 08 +74  
The matter got a bit complicated because the <LI> tags were not closed and inside some of the list items are other tags, so some re-assembly needed to be done.

I have no idea how you want to handle the lists-inside-lists thing, so I just ignored this and made these into one flat array.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James


In reply to Re: Can't Write to Files properly by CountZero
in thread Can't Write to Files properly by sdyates

Title:
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, 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:
    & &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.