From within Perl, you can execute any other command with the backtick operator. So my $foo = `foo` will execute the program "foo" and return anything it wrote in its standard output into the variable $foo. However, all such commands execute in a sub-process. In other words, if the program `foo` changes the current directory or sets some environment variables, this will not be reflected when Perl resumes execution (unlike when sourcing one shell script within another). In Perl you use the global hash %ENV to set environment variables and the chdir() builtin to change directories.
You should not, however, use this technique to load Perl modules. Instead you should use the use declaration. See the Simple Module Tutorial in Tutorials.
In reply to Re: source a program
by Errto
in thread source a program
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |