roho has asked for the wisdom of the Perl Monks concerning the following question:
\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."
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Unexpected Error: \C no longer supported in regex (updated x2)
by AnomalousMonk (Archbishop) on Aug 20, 2022 at 02:31 UTC | |
by roho (Bishop) on Aug 20, 2022 at 03:49 UTC | |
Re: Unexpected Error: \C no longer supported in regex
by kcott (Archbishop) on Aug 20, 2022 at 09:18 UTC | |
by roho (Bishop) on Aug 22, 2022 at 05:36 UTC | |
Re: Unexpected Error: \C no longer supported in regex
by atcroft (Abbot) on Aug 20, 2022 at 22:30 UTC | |
by roho (Bishop) on Aug 22, 2022 at 05:45 UTC |