Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Can't Write to Files properly

by CountZero (Bishop)
on Dec 04, 2011 at 20:48 UTC ( [id://941761]=note: print w/replies, xml ) Need Help??


in reply to Can't Write to Files properly

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

Replies are listed 'Best First'.
Re^2: Can't Write to Files properly
by planetscape (Chancellor) on Dec 04, 2011 at 22:21 UTC

    I sure hope you collect your $20.

    HTH,

    planetscape
      I'll gladly exchange that $20 for some good karma.

      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

Re^2: Can't Write to Files properly
by sdyates (Scribe) on Dec 04, 2011 at 21:02 UTC
    Thanks so much. This is perfect and give me what I need to figure it out. Thanks for being patient and taking the time. Regards, S

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://941761]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-20 04:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found