Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Regex To Remove File Extension

by grep (Monsignor)
on Dec 10, 2008 at 21:09 UTC ( [id://729507] : note . print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    index.html
    foo.pl
    CGI.pm
    video.mpeg
    foo.pl~
    
  2. or download this
    .foo
    .bar
    
  3. or download this
    my @names = qw/ index.html foo.pl CGI.pm video.mpeg foo.pl~ .bash_hist
    +ory .bash_rc /;
    foreach my $string ( @names ) {
    ...
        $string =~ s/(.+)\.[^.]+$/$1/;
        print "$string\n";
    }