in reply to Extract main name of file

Windows and Unix compatible way to extract filename.
my $ME = $0; $ME =~ s/.*[\\\/]//; # $ME =~ s/\.[^.]+$//;
The extension is not removed, because the script placed in $PATH is still invoked by the name and extension. Another reason to leave the extension - its definition is weak in all operating systems. However sometimes you need the bare filename (for example script.pl requires script.conf). To cover this requirement uncomment the last line above. However if you need do it in mass - better choice to use modules. For example, already suggested by other responders.