How to use 'do' on a Perl script and avoid multiple subroutine definitions?
I'm trying to call a Perl script from another Perl script. The way I'm accomplishing this is the following:
local @ARGV = (
$arg1,
$arg2
);
do 'perl_script.pl';
The reason I'm using 'do' instead of using 'system()' is that this old codebase involves calling multiple Perl scripts which in turn are calling multiple Perl scripts (Now of course I could refactor everything into Perl modules but that is not worth it at this point).
Using 'do' instead of 'system()' allows easier debugging with the '-d' flag and avoids unnecessary system calls. The problem I'm running into is that 'do' will fail if calling the same perl scripts more than once because the Perl scripts have subroutines defined in them, and calling the script more than once leaves me with 'subroutine redefined' errors.
Is there another way to do this besides 'do' or some way to ignore subroutines that are redefined?