Help Required !!!!

V

vandana

Hello,

# strip (trailing) filename from path, leaving directory only

my ($path) = $ENV{'PATH_TRANSLATED'} =~ m|(^.*)\\|;

It removes trailing filename from path. Can anyone help me to
understand the working of
m|(^.*)\\|; in above command.

Regards
Vandana
 
D

David Squire

vandana said:

Hello Vandana,

Welcome to this group. Might I suggest that a good starting point for
you would be to read the posting guidelines that are posted here several
times a week. In particular, they give advice on how to maximize your
chances of getting a useful response, by doing such things are using a
meaningful subject line for your post.

# strip (trailing) filename from path, leaving directory only

my ($path) = $ENV{'PATH_TRANSLATED'} =~ m|(^.*)\\|;

It removes trailing filename from path. Can anyone help me to
understand the working of
m|(^.*)\\|; in above command.

You need to read Perl's documentation on regular expressions, and the
match and substitution operators that use them. Perl comes with its
documentation included. You can access it using the perldoc command on
the command line. Try "perldoc perlre", "perldoc perlop", and "perldoc
perlretut". You can also read the documentation online at
http://www.perl.com/pub/q/documentation

Regards,

DS
 
C

cartercc

vandana said:
Hello,
It removes trailing filename from path. Can anyone help me to
understand the working of
m|(^.*)\\|; in above command.

m # matches the left value
| # the delimiter for the regular expression
( # beginning of whatever is saved
^ # matches the beginning of the line
.. # matches any character up to whatever follows
* # matches greedily any number of characters from zero upward
) # ends the recording of charachter - paired with the opening parens
\ # the escape character
\ # the character escaped, possibly a Windows path delimiter
| # the delimiter of the regular expression - paired with the opening
pipe
; # ends the expression

Suggest you sit down with the Perl documentation and read the pages on
regular expressions.

CC
 
J

John W. Krahn

vandana said:
# strip (trailing) filename from path, leaving directory only

You probably want to use the File::Basename::dirname function for that:

perldoc File::Basename


John
 
J

Jürgen Exner

vandana wrote:

Please put the subject of your post into the Subject of your post
# strip (trailing) filename from path, leaving directory only

There are ready-made modules for that task (See File::Basename) which are
tried and proven and work regardless of the platform used.
my ($path) = $ENV{'PATH_TRANSLATED'} =~ m|(^.*)\\|;

It removes trailing filename from path.
Can anyone help me to
understand the working of
m|(^.*)\\|; in above command.

See perldoc perlop for the 'm' operator.
See perldoc perlretut and perldoc perlre for the RE.

jue
 
T

Tad McClellan

vandana said:
Subject: Help Required !!!!


You will get more people to help if you compose a meaningful
Subject line.

Every post here requires help. Do you think that question-answerers
read every post? They don't. They read the ones with interesting
subjects, which your's isn't.

Please see the Posting Guidelines that are posted here frequently.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top