in reply to Exporting variables between two perl files

Contrarily to gube, I assume that one of the scripts is some kind of "slave" (you talk about using one from the other) of the other, and not that they are allowed to be executed independently. What I mean is that if you need to have two scripts to be executed independently, and operate on some shared value, you should try to follow gube's suggestion. OTOH, if you just want to put some configuration values inside one file, and grab them from the other, read on.

For reasonably recent Perl, you can use the our keyword, which works similar to my but it's not the same, of course. In file1.pl:

#!/usr/bin/perl use strict; use warnings; our $var = 1;
In file2.pl:
#!/usr/bin/perl use strict; use warnings; our $var = 10; print "\$var is $var\n"; do "file1.pl"; print "\$var now is $var\n";
You get:
poletti@flaviox ~/sviluppo/perl> perl file2.pl $var is 10 $var now is 1
For previous versions of Perl, you can obtain similar results with use vars (see http://perldoc.perl.org/vars.html, noting that it is now obsolete).

Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf

Don't fool yourself.