Re: Removing file extension

2007-01-24 Thread Dr.Ruud
Xavier Noria schreef: > On Jan 23, 2007, at 9:55 AM, Dr.Ruud wrote: >> [thread repaired] Saravana Kumar: >>> 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

Re: Removing file extension

2007-01-24 Thread Dr.Ruud
Xavier Noria schreef: >$file =~ s/\.\w+$//; That solution is broken, think "file.txt~" and "file.$$$", etc. :) -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Removing file extension

2007-01-24 Thread Xavier Noria
On Jan 23, 2007, at 9:55 AM, Dr.Ruud wrote: Use an anchor and a negated character set: s/\.[^.]*$// That solution is broken, think "/foo/bar.baz/woo". Correct regexps and other approaches have already been posted. -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comm

Re: Removing file extension

2007-01-23 Thread Dr.Ruud
Saravana Kumar schreef: > 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 nam

Re: Removing file extension

2007-01-23 Thread John W. Krahn
Igor Sutton Lopes wrote: > > On 2007/01/23, at 11:03, Rob Dixon wrote: > >> $file =~ s/(.*)\./$1/; >> >> or >> >> $file =~ s/\.[^.]*$//; > > If you know the suffix of the files you're working on, you can use the > File::Basename module, more specific the fileparse function: > > use File::Basen

Re: Removing file extension

2007-01-23 Thread Igor Sutton Lopes
On 2007/01/23, at 11:03, Rob Dixon wrote: $file =~ s/(.*)\./$1/; or $file =~ s/\.[^.]*$//; If you know the suffix of the files you're working on, you can use the File::Basename module, more specific the fileparse function: use File::Basename; my @suffix = qw(.txt .zip .doc); my $filep

Re: Removing file extension

2007-01-23 Thread Rob Dixon
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

Re: Removing file extension

2007-01-23 Thread Xavier Noria
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 s

Re: Removing file extension

2007-01-22 Thread Saravana Kumar
shaick mohamed wrote: > Try this > s/(.*)\..*/\1/; > > Thanks, > Shaick. > > On 1/23/07, Saravana Kumar <[EMAIL PROTECTED]> 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/\..*/

Re: Removing file extension

2007-01-22 Thread shaick mohamed
Try this s/(.*)\..*/\1/; Thanks, Shaick. On 1/23/07, Saravana Kumar <[EMAIL PROTECTED]> 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'

Removing file extension

2007-01-22 Thread Saravana Kumar
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