• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

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.
0
oostwijk
Asked:
oostwijk
1 Solution
 
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
 
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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now