in reply to Getting a result from "foreach" block

push(@r);

Tip #1 from the Basic debugging checklist: warnings

Useless use of push with no values at ...