#!/usr/bin/perl -w use strict; my $str = "This_is_a_song_.mp3"; $str =~ s/_(\.mp3)$/$1/g; print "$str\n";