Perl Programming Question:

Download Job Interview Questions and Answers PDF

How do I set environment variables in Perl programs?

Perl Programming Interview Question
Perl Programming Interview Question

Answer:

you can just do something like this:
$ENV{'PATH'} = '...';
As you may remember, "%ENV" is a special hash in Perl that contains the value of all your environment variables.
Because %ENV is a hash, you can set environment variables just as you'd set the value of any Perl hash variable. Here's how you can set your PATH variable to make sure the following four directories are in your path::

$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/home/yourname/bin';

Download Perl Programming Interview Questions And Answers PDF

Previous QuestionNext Question
Why do you use Perl?Which of these is a difference between C++ and Perl?