S.A. Birl wrote:
> Im doing some file renaming.
> 
> Im looking to subtitute all but the last . into _
>       ie: filename.jpg.pgp   --> filename_jpg.pgp
>       ie: filename.2.jpg.pgp --> filename_2_jpg.pgp
>       ie: file....._.jpg.pgp --> file__________.pgp
> 
> 
> Ive tried about 10 different expressions, but they've all failed.
> The closest one I have is
>       s/\.[^[\..+$]]/_/;
> 
> But I cant wrap my mind around the correct expression.  Help.

$ perl -e'
my @files = qw[ filename.jpg.pgp filename.2.jpg.pgp file....._.jpg.pgp ];
for my $file ( @files ) {
    print "$file --> ";
    $file =~ s/\.(?=.*\.)/_/g;
    print "$file\n";
    }
'
filename.jpg.pgp --> filename_jpg.pgp
filename.2.jpg.pgp --> filename_2_jpg.pgp
file....._.jpg.pgp --> file_______jpg.pgp





John
-- 
use Perl;
program
fulfillment

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


Reply via email to