On Jan 23, 2007, at 8:22 AM, Saravana Kumar wrote:

Hi list,

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?

Yes, you need to assert in the regexp dots are not allowed in the extension, for example something like this:

  $file =~ s/\.\w+$//;

Note that no captures are needed.

-- fxn


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


Reply via email to