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::Basename; > > my @suffix = qw(.txt .zip .doc); > my $filepath = "/tmp/something.txt"; > my ($name, $path, $suffix) = fileparse($filepath, @suffix);
You don't need to know the "suffix" name(s), just use a regular expression: my $filepath = '/tmp/something.txt'; my ( $name, $path, $suffix ) = fileparse( $filepath, qr/\.[^.]*/ ); John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/