in reply to Help with regex using variables
G'day FFSparky,
You seem to have a number of problems.
Consider this example script (pm_11152209_re_backslashes.pl) which is portable:
#!/usr/bin/env perl use strict; use warnings; my $search = 'C:\Dir1\Dir2\Dir3'; my $replace = ''; my $var = 'C:\Dir1\Dir2\Dir3\KeepMe'; $var =~ s/\Q$search/$replace/; print "\$var[$var]\n";
On Cygwin:
ken@titan ~/tmp $ perl -v This is perl 5, version 36, subversion 0 (v5.36.0) built for cygwin-th +read-multi ... ken@titan ~/tmp $ ./pm_11152209_re_backslashes.pl $var[\KeepMe]
On Win10:
C:\cygwin64\home\ken\tmp>perl -v This is perl 5, version 26, subversion 3 (v5.26.3) built for MSWin32-x +64-multi-thread ... C:\cygwin64\home\ken\tmp>perl pm_11152209_re_backslashes.pl $var[\KeepMe]
— Ken
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Help with regex using variables
by FFSparky (Acolyte) on May 17, 2023 at 15:06 UTC |