Most of your problem here is caused by having subroutines that are only called for their side effects on global variables. A better approach would probably be to use subroutines which return values.
#!/usr/bin/perl # pie.pl use strict; my $pie; require "b.pl"; $pie = &getpied; print "The pie says : $pie\n";
and
#!/usr/bin/perl # b.pl use strict; sub getpied { return "eat me"; } 1;
An even better approch would be to look into turning b.pl into a real module.
Update: Oops. Just saw the part where you said
Using return is not an option, as I have a whole lot of variables that has to be available in about 8 different scripts.
(thanks to Skeeve for pointing it out)
In that case, you really need to turn b.pl into a module and use Exporter.
--"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: 'use strict;' between libraries
by davorg
in thread 'use strict;' between libraries
by Massyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |