in reply to javascript to html to perl

I would do something like this... lets pretend that your document is in $data

print join('',($data =~ m/document\.write\(['"]([^)]+)['"]/sg));
This would print everything enclosed within document.write() throughout the doc.

Hope this helps,
  -Adam

Replies are listed 'Best First'.
Re^2: javascript to html to perl
by rduke15 (Beadle) on May 10, 2005 at 23:18 UTC

    Yes, that was my first approach. But it is very fragile. To begin with, there are plenty of escaped double-quotes. These wouldn't be hard to take care of, but it will inevitably continue with stuff breaking my regexes.

    I don't want to end up trying to write a javascript parser in Perl, when there are excellent javascript interpreters already in the browsers. There must be a way to make them work for my Perl script instead of the browser window.

      Well, the regex above will still work with escaped quotes... it will match until the last quotemark before the end parentheses, so all escaped quotes get included.

        -A