param name= stuff but we lack param name=src linking to a file! Below the param name comes the embed src=link to file! tag. So, what we want to do is get that link from embed, in each individual 'body' field, and create a param name src with the same link and add this to this same 'body' field. add (wildcard) where like% solution I could do, I'm stumped?
number, date, HTML stuff RANDOM stuff RANDOM stuff RANDOM stuff#!/usr/bin/perl -wuse strict;use DBI;use HTML::Parser;my $dbh = DBI->connect( 'DBI:mysql:database=mydb;host=myhost.example.org', 'myuser', 'mypass', { RaiseError => 1 } ) || die "Cannot connect to database: $!";my $sth_update = $dbh->prepare( 'UPDATE `mytable` SET `body` = ? WHERE `id` = ?' );my $sth_select = $dbh->prepare( 'SELECT `id`, `body` FROM `mytable`' );my ($id, $body);$sth_select->execute;$sth_select->bind_columns( \$id, \$body );while ($sth_select->fetch) { my $tree = HTML::TreeBuilder->new; $tree->parse( $body ); $tree->eof; $tree = $tree->elementify; # skip if this already has a src PARAM next if $tree->look_down( '_tag' => 'param', 'name' => 'src' ); my $embed = $tree->look_down( '_tag' => 'embed' ); next unless $embed; my $param = HTML::Element->new( 'param', 'name' => 'src', 'value' => $embed->attr( 'src' ) ); $tree->unshift_content( $param ); $sth_update->execute( $tree->as_HTML, $id );}You are not logged in, either login or create an account to post comments
Any chance you can simplify your question?
I understood correctly, you've got some html in a database and you want to add where BLAH is taken from . Is this right?
If so, you can do this with an sql query using substr() and position functions. Much better, and easier to read would be to fetch each row, manipulate and update it using Perl or something.
posted by devnull at 2:40 AM on January 21