lazy capture don't work (regexp in perl)

hello all
im trying to capture only the first brackets but no matter what i do i keep capturing from the first brackets to the last one , here what i have :
<% if (!Env.strLen(oidInvoice)); szDocumentTitle = Env.formatS("S",Env.getMsg("BP_INVOICE_ENUMERATION_CREATE_TITLE")) %>

and the regexp i have is :

if($r=~ m/<%\s*(if\s*\(.+?\))\s*%>/gi){
.....
}

i like to capture only : if (!Env.strLen(oidInvoiceEnum))
with no luck what im doing wrong?

Omit leading <%\s* and trailing *%>

#!/usr/bin/perl

while (<>) {
    if(m/(if\s*\(.+?\));/gi){
        print $1,"\n";
    }
}

Also you have a trouble becouse of quotes inside quotes, so you must stick with ';'

$ echo '<% if (!Env.strLen(oidInvoice)); szDocumentTitle = Env.formatS("S",Env.getMsg("BP_INVOICE_ENUMERATION_CREATE_TITLE")) %>' | ./1.pl 
if (!Env.strLen(oidInvoice))