perf/scripts: Move common code out of Perl-specific files