{
push @next, $p->get_token();
if ($next[1][0] eq 'T')
{
my $title= $next[1][1];
#strip white space from title and get up to four words
if ($title =~ /(\w+)\s*(\w+)\s*(\w+)\s*(\w+)/)
{
my $filetitle = $1 . $2 . $3 . $4;
my $newsrc = $filetitle . "\.jpg";
while ( $token=$p->get_token() )
{
if ($token->is_start_tag('img') )
{
my $src = $token->return_attr->{src};
$token->set_attr('src', $newsrc);
}
print FILE $token->as_is;
}
}}}
In keeping with wishes, and genies, and not trying people's patience, I ask my third and last question on this code...Is there a way to put a token back into the stream so that I can keep the file's title text? UPDATE:Taking a step or two back from this I realized a simple answer to my own question. I just added a print FILE $title; statement in after the regex and it did what I needed. I was so wrapped up in parsing the HTML that I had lost the thought that I could use another approach. Thanks, Monks, as always for your assistance. |