1 - Yes, the regex works fine, but so does all of the code. I.e., I see nothing wrong with the context, but maybe I'm not grokking something. I threw parentheses around the *{4}filename.ext*{4} portion of the regex and it was stored in the array properly, too.
2 - Perhaps maddfisherman was looking in $template1 instead of $template[0] ?
apprentice
Comment on Re: putting regex results into an array. (boo)
One thing I missed the first look, you need to escape the "@template" in the string like this "\@template" else your string, and hence the first element of @template will not have "@template".