...

/

Supplying Environment Variables to Specific Programs

Supplying Environment Variables to Specific Programs

Learn how to supply environment variables to specific programs.

We'll cover the following...

Perl script

Sometimes, we have a script or program that needs some variables from the environment. Still, we don’t need or want to set these values forever, or we need to override values in our environment temporarily. We can do this by prefixing the command with the variables we need.

To demonstrate this, let’s create a quick Perl script that grabs values from the environment and prints them out. Perl is great for this because it’s already installed on macOS and Ubuntu, and it makes it easy to write a small program to illustrate this concept.

First, we create a file named variables that reads the variables ...