Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Need to capture an optional sub-directory name

by spazm (Monk)
on Mar 29, 2012 at 16:26 UTC ( #962437=note: print w/replies, xml ) Need Help??


in reply to Need to capture an optional sub-directory name

You way want to look into a module like File::Spec or Path::Class that allows manipulation of file paths to use the fact that you know this is a path situation.
use File::Spec sub SriptName { my ($self) = @_; my $name = Win32::GetFullPathName($0); my ($volume, $dirs, $file ) = File::Spec->splitpath( $name ); my (@dirs) = File::Spec->splitdir( $dirs ); $_ = shift @dirs until $_ eq 'scripts'; #drop all suffix (not sure if this is what you want here) # this could/should also be $file = basename($file) $file =~ s/\..*//; return join( ' - ', @dirs, $file) }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://962437]
help
Chatterbox?
[marto]: Discipulus Let's discuss Podmaster's Signature and the response from tye
[Discipulus]: thanks marto i'll read it after an urgent phonecall
[choroba]: I configured signature font to 2pt size, so I don't care
[choroba]: Moreover, I don't find the Big Lebowski quote offensive

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2017-06-23 09:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (539 votes). Check out past polls.