Easy Question

Hello, Can someone tell me how to write this code ? I want to strip of the extension (including dot) of a variable.
I've something in mind like this:
$filename="File.txt";
This variable must be stripped..so that I will get
$filename="File";

Hope that you can help me out.
oostwijkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

maneshrCommented:
The foll will also take care of file, in UNIX, of the format file.ext.ext
Eg  file.txt.mine

$filename=~ s/(.*)\..*$/$1/;

print $filename;
0
elpmetCommented:
# suppose $filename contains "file.txt"

($filename)=split(/\./,$filename);


Tell me if this is not what you wanted.

Elpmet
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozoCommented:
If there are more than one dots, would you want to strip all of them or just the last one?
0
oostwijkAuthor Commented:
That's what I mean, perhaps you could also take a look at my other question
'Easy Question 2'
Keep up the good work.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.