What are you using to parse the source at present? Are you looking for a chunk of code using regexen and loops, or something you can plug into a Parse::RecDescent rule set?
The following sketch code for handling the problem using regexen may help:
use strict;
use warnings;
while (<DATA>) {
s/\[\[(\w+)/parseHereDoc ("$1")/e if /\[\[\w+/;
print;
}
sub parseHereDoc {
my $id = shift;
my $str = '"';
while (<DATA>) {
last if /^$id$/;
$str .= $_;
}
return $str . '"';
}
__DATA__
var = [[END . "other stuff";
heredoc
data
END
Prints:
var = "heredoc
data
" . "other stuff";
Perl is environmentally friendly - it saves trees