for (qx){ s/\|/ /; my ($Image) = split; for (qx){ next unless m/Media ID|Data Expiration/i; qx; } }