Re: file name without the extension
am 03.04.2006 14:17:14 von Paul Lalli
George Bouras wrote:
> I want to grab the file name without the extension and without using a
> module.
Can you possibly explain what reason you have for re-inventing this
wheel? When a solution already exists, and is available in the
standard distribution of Perl, why would you want to ignore it and make
an attempt to write your own?
Paul Lalli
file name without the extension
am 03.04.2006 22:18:28 von George Bouras
I want to grab the file name without the extension and without using a
module. I have a working solution with two regular expressions but I
wonder if it can be done with only one regional expression.
For all the following $node_path the $node_body should be "file".
my $node_path = 'c:/dir.1\dir2\file.bin';
my $node_path = 'c:/dir.1\dir2\file';
my $node_path = 'file.bin';
(my $node_body = $node_path) =~s/.*?([^\\\/]*)$/$1/;
$node_body =~s/\.[^\.]*\s*$//;
print $node_body; # file