Hello mongers,

I am pulling some entries out of Moveable Type blog and converting them
to Docbook (long story). In any given weblog entry, there might be a big
hunk o' Javascript in an otherwise fine piece of text. (typically, the
javascript launches a pre-sized window with a jpg in it). 

My goal is to preserve the string except the javascript part. The
javascript needs a little modification. Maybe I should 'splain with
code:

$text = 'para 1
         javascript_with_href_to_image1_string
         para 2
         javascript_with_href_to_image2_string
         para 3';

If I wanted to just whack the javascript except the href string inside
of it, I'd do something like this:

$text =~ s!javascript_with_(.*)_string!$1!g;

so now I have...

$text = 'para 1
         href_to_image1
         para 2
         href_to_image2
         para 3';

But what I would really like to do is wrap $1 around a big set o'
Docbook tags. I figured I would just call  a function to do that, but it
doesn't work. 

$text =~ s!javascript_with_(.*)_string! trans($1) !g;

sub trans {
    my $foo = shift @_;
    return "<several-nested-tags>$foo</several-nested-tags>\n";
}

I'm poking with 'man perlre', but not making much headway. Can I call a
function in the substitution part of a regexp match?

Love, Luck, and Lollipops,

--Larry


 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to