Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

pulling strings from html files...

by martymart (Deacon)
on May 27, 2003 at 11:00 UTC ( [id://260959]=perlquestion: print w/replies, xml ) Need Help??

martymart has asked for the wisdom of the Perl Monks concerning the following question:

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

Replies are listed 'Best First'.
Re: pulling strings from html files...
by allolex (Curate) on May 27, 2003 at 11:47 UTC
Re: pulling strings from html files...
by crenz (Priest) on May 27, 2003 at 11:15 UTC

    This is not directly a reply to your question, but for handling the translations of your texts, take a look at

    As for handling your HTML files, it would actually be easier if you were to use a templating system to separate content from presentation. Just a suggestion for the future...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-16 21:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found