Fellow Monks,

I would like to hear your thoughts on the following... I have a large bunch of html files... they are eventually going to be copied and any localisable strings in them (US strings naturally) is going to be replaced with locale text (German for example). Replacing the text in these files is easy enough, its pulling the relevant strings out to some text file for the translators thats giving me grief. I've tried using HTML::PullParser and it seems to work quite well at pulling out strings, any thoughts on how to get this to work for alt text aswell?? as its used quite a bit

#!/usr/bin/perl use warnings; use strict; use HTML::PullParser; OPEN (SOURCE, "Somehtmlfile.html")||die"Can't create $1: $!"; my @source=<SOURCE>; close (SOURCE); my @dest=strip ("@source"); print "@dest"; sub strip { my $html = shift; my $parser = HTML::PullParser->new( doc => $html, text => 'text', ); my $result = ''; while(my $t = $parser->get_token) { $result .= $t->[0]; } return $result; };
Am I going about this the right way? Many Thanks
Martymart

In reply to pulling strings from html files... by martymart

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.