in reply to regex to rename last _ with ,

If you know how to replace the first underscore with a comma, just add reverse:
$file = reverse $file; $file =~ s/_/,/; $file = reverse $file;

To get back what's after the inserted comma, the following should work:

$file =~ s/_([^_]*)/,$1/; my $rest = $1;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: regex to rename last _ with ,
by ArifS (Beadle) on Sep 11, 2014 at 14:00 UTC
    it was that easy!.... thank you.