Link to home
Start Free TrialLog in
Avatar of oostwijk
oostwijk

asked on

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.
Avatar of maneshr
maneshr

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;
ASKER CERTIFIED SOLUTION
Avatar of elpmet
elpmet

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
If there are more than one dots, would you want to strip all of them or just the last one?
Avatar of oostwijk

ASKER

That's what I mean, perhaps you could also take a look at my other question
'Easy Question 2'
Keep up the good work.