Saravana Kumar wrote:
>
shaick mohamed wrote:

On 1/23/07, Saravana Kumar <[EMAIL PROTECTED]> wrote:

I am trying to remove the extension from the a list of filenames and
manipulate the names further.

Tried to doing this:
$file=~ s/\..*//;

The above works fine. I get the result 'filename' if the filename is
filename.ext.

There are some files whose names are like file.name.ext and the result i
get for this is 'file' while the desired result is 'file.name'. Is there
a way to fix this?

Try this
s/(.*)\..*/\1/;

I got this warning:
\1 better written as $1

But the result was what i expected(file.name)

(Please bottom-post all responses. Thank you.)

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

or

$file =~ s/\.[^.]*$//;

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to