package ex::NameExe; use strict; use warnings; use File::Spec::Functions qw(splitpath splitdir catdir catpath catfile); use File::Copy; $|++; my (undef,undef,$script)=splitpath($0); $script or die $0; my ($v,$path,$exe)=splitpath($^X); $path=$v.$path; $script.=".exe"; my $new_exe=catfile($path,$script); unless ($exe eq $script) { copy $^X,$new_exe or die "$^X = > $new_exe:$!" unless -e $new_exe; exec $new_exe,'"-Mstrict;BEGIN{$|++};"',$0,@ARGV; die "Failed to re-execute as $new_exe!"; } 1;