in reply to backticks with system()

Use (pun definitely intended) strictures e.g. use warnings; use strict; !! That would point out that there's a missing right brace '}' completing the foreach block.

Is there a specific reason for your use of system with /bin/echo ... instead of print ??

A user level that continues to overstate my experience :-))