Get file extention from path

R

Ron

I need to get the file extension from a path(file location+file
name+extension)

This code get's me to the file name + extension.

My beginner question is. How do I get just the extension?

my $filename1 = $FILE1;
$filename1 =~ s/^.*(\\|\/)//;
$filename1 =~ s/ +/\_/g;

Thanks,
Ron
 
R

Ron

Thanks Tina although I am not sure who to put that into code I tried

my $ext1 = $FILE1(function fileparse());

How do I use it?

Thanks,
Ron
 
R

Ron

Thanks Sinan,

I am so new I did not even know about TFM.

I did take the time to read the posting guide lines & thought of you when I
read the first paragrah.

" A note to newsgroup ``regulars'':
Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume"
 
A

A. Sinan Unur

Thanks Sinan,

I am so new I did not even know about TFM.

I did take the time to read the posting guide lines & thought of you
when I read the first paragrah.

" A note to newsgroup ``regulars'':
Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume"

Hmmmm ... my post was no flame.

And please stop top-posting.

BTW,
my $ext1 = $FILE1(function fileparse());

is profoundly weird, and indicated to me that you spent no effort. A simple
Google search for fileparse returns the link I gave you as the first match:

http://www.google.com/search?sourceid=navclient&q=fileparse

so you did not even have to know where the docs are located on your
computer.

Sinan.
 
R

Ron

Shawn Corey said:
Hi,

perldoc File::Basename

Read about fileparse.

Thanks I read the doc. I hate to ask for more help but here goes.
From the doc I got;
Similarly, using VMS syntax:

($name,$dir,$type) = fileparse('Doc_Root:[Help]Rhetoric.Rnh',
'\..*');





When I run this code I get a server error?
I am trying to get the file extention from $FILE1.


fileparse($FILE1 ,'\..*');
My $MyExt1 eq $type

Any Suggestions or code I might use?

Thanks,
Ron
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top