Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Extract main name of file

by siberia-man (Friar)
on Mar 03, 2022 at 10:51 UTC ( [id://11141788]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11141788]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-19 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found