\C no longer supported in regex; marked by <-- HERE in m/C:\Book\ <-- HERE C0001-Chapter-001.mp3/ at C:\tmpx\xx.pl line 15.
I have a workaround, which is to change the backslashes to forward slashes before performing the regex substitution, then changing the forward slashes back to backslashes, which seems kind of kludgy.
Any ideas on how to overcome the "\C" error message? I have tried running the text through "qr" but that does not help. I have tried both "e" and "ee" regex suffixes but that does not help either.
In the following code, comment out the "Workaround" lines that change backslashes to forward slashes to see the error.
#!/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";
"It's not how hard you work, it's how much you get done."
In reply to Unexpected Error: \C no longer supported in regex by roho
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |