#!/usr/bin/perl use strict; use warnings; my $txt = "C:\\Book\\C0001-Chapter-001.mp3"; my $new = "C:\\Book\\NEW-C0001-Chapter-001.mp3"; print "\n"; print "Before: $txt\n"; # Workaround -- Change backslashes to forward slashes. $txt =~ s/\\/\//g; $new =~ s/\\/\//g; $txt =~ s/$txt/$new/; # Workaround -- Change forward slashes back to baskslashes. $txt =~ s/\//\\/g; $new =~ s/\//\\/g; print "After: $txt\n"; print "\n";