Sunday, November 19, 2006

finding includes in html

For the second time in the a few months I've wanted to be able to fish through the includes in an shtml file in perl.

This while statement will itterate once for each time it matches a pattern for a virtual include, letting me check to see if the include is there, slurp it up, whatever:


while ($file_contents =~ m{<!--#?include\s+virtual="([^"]*)"\s*-->}gis){
# do something with $1 (a path)
}

No comments: