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.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>