my $title = "something"; my $executable = "C:/Users/Desktop/file.exe"; my $output = "C:/Users/Desktop"; my $outfile = "C:/Users/Desktop/$title.in"; open(OUTFILE,">$outfile") or die "Can't open output file $outfile\n"; print OUTFILE @array; close OUTFILE; my $msg = $mw->messageBox(-icon => "info", -type => "OK", -title => 'Save', -message => "File was successfully saved."); chdir $output; system("$executable","$title",) == 0 or die "system $executable failed: $?";