my ( $name ) = ( $0 =~ /(.*)\.pl/ ) ;

$name =~ s/^(.*\\)// ; # erase full path names, they give problems creating mutexes

( $name ) = ( $^X =~ /(.*)\.exe/ ) if ( $name eq '' ) ; # Compatibility for perl2exe