Perl Add Directory to Path

Say you have a directory d:bin and you want to add it to path environment at the beginning of your Perl script. Following code will do the trick.

my $dir="d:\bin";
$ENV{PATH}.=";$dir";

Then $dir will be included in new $ENV{PATH}

Leave a Reply

Your email address will not be published.