Not a problem.  \Q means quotemeta, except immediately following
a interpolated identifier.  You want to start metaquoting immediately
after a curious interpolation? use \Q\Q.


I have been regularly, since I fingured out how, doing things like


        print "the time is now ${\(~~localtime)}[go home!]";  # double-not
"scalar" golf hack

in p6 without "weird brackets" I supposed this becomes

        print "the time is now $(+localtime)\Q[go home!]"; 

Right?  So if I wanted to quotemeta this thing so I could let sh have it
safely, what in apo2 is preventing me from writing

        print "the time is\Q now < $(+localtime)\Q[go home!] \E"; 

the only time there's an ambiguity is when the metaquoting starts
immediately
after the stopped variable identifier

        print SH "echo the time is now `date` so go $destinations{first}\Q\Q
<$tainted> \E"; 
 perl -le'print "\Q\Q\Q <<\E<\E< \E <"'
\\\\\\\ \\\\\\\<\\\\\\\<\\\<\<\  <

metaquote stacks -- why not use \E instead?  it has the same issues, but
has
no effect at all currently, and E is for End_of_interpolble_specifier a lot
more than \Q does.

\Q\E is a safe zero-length noninterpolable in any context however, with
no side effect


Garrett Goebel wrote:
> 
> From: Larry Wall [mailto:[EMAIL PROTECTED]]
> > Richard Proctor writes:
> > : In Apocalypse 2, \Q is being used for two things, and I
> > : believe this may be ambiguious.
> > :
> > : It has the current \Quote meaning admitibly \Q{oute} it is
> > : also being proposed for a null token disambiguate context.
> > : As in $foo\Q[bar].
> >
> > Hmm, yes, that's a problem.  I'd forgotten about the quotemeta kludge.
> > I'll have to think about it.  Maybe quotemeta becomes \qm{}
> > or some such.
> 
> The problem with \Q quotemeta was the biggest thing to jump out at me when
> reading A2... That is before my brain turned to mush. Seems like quotemeta
> be serving its purpose if you have to consider escaping its contents...
> What's the Perl6 equivalent to:
> 
> #!perl -w
> # script.pl:
> my ($match, $filename) = @ARGV;
> local $/;
> open FH, $filename;
> $file = <FH>;
> print scalar @{[$file =~ m/(\Q$match\E)/gs]};
> 1;
> __END__
> 
> file.txt contents:
> {foo}\E{foo}\E{foo}
> 
> > script.pl {foo} file.txt
> 3
> >

-- 
                      David Nicol 816.235.1187 [EMAIL PROTECTED]
                                              Parse, munge, repeat.

Reply via email to