#!/usr/bin/perl use strict; use warnings; use Cwd qw/chdir/; # comes in standard Perl distro my $bar = "someprogramname"; chdir("/foo") or die "Couldn't cd to /foo!\n"; system("$bar\.exe") or die "Couldn't execute $bar\.exe!\n";