You need to give $myvar a value in each snippet. Greedy => '$myvar =~ /"(.*)"/',
becomes Greedy => '$myvar = "Some String"; $myvar =~ /"(.*)"/',
For more advice see the node Benchmarking Your Code.
Update: I see that I located the problem (scoping), but not the cause.(the my)