in reply to qr/string/ is not the same as qr/$var/ ?
I also get the same warning on my home machine (v5.8.4 built for i386-linux-thread-multi)[dean:~]$ perl -v This is perl, v5.8.1-RC3 built for darwin-thread-multi-2level (with 1 registered patch, see perl -V for more detail) Copyright 1987-2003, Larry Wall ... [dean:~]$ cat /tmp/deleteme.pl #!/usr/bin/perl use strict; use warnings; my $patt = shift; $patt = qr/$patt/; my $target = shift || 'aBC'; print "'$target' =~ $patt\n"; print $target =~ $patt; print $/; [dean:~]$ /tmp/deleteme.pl 'a\Ubc' Unrecognized escape \U passed through in regex; marked by <-- HERE in +m/a\U <-- HERE bc/ at /tmp/deleteme.pl line 6. 'aBC' =~ (?-xism:a\Ubc)
Good Day,
Dean
Update: If you're only interested in \Q, a more sane hack than eval might be to call quotemeta yourself, something like this, but with quotemeta:
#!/usr/bin/perl use strict; use warnings; no warnings "uninitialized"; my $patt = 'a\Ubc'; $patt =~ s/(^|[^\\])(\\\\)*\\U(.*?)(?:\\E|$)/$1.$2.uc($3)/se; $patt = qr/$patt/; my $target = 'aBC'; print "'$target' =~ $patt\n"; print $target =~ $patt; print $/;
Update 2: Oops, I missed your "erk" about hand-parsing the pattern. Sorry to suggest it.
|
|---|