"John L. Allen" wrote:

> On 29 Sep 2000, Perl6 RFC Librarian wrote:
>
> > Make Perl's powerful string interpolation facilities are available to
> > variables, in addition to literals.
> >
> > =head1 DESCRIPTION
> >
> > Given:
> >
> > $foo = 'def';
> > $bar = 'ghi';
> > $x = "abc$foo$bar";
> > $y = 'abc$foo$bar';
> >
> > There is no  way to turn obtain the  value of $x from the  value of $y.
> > In other  words, while  $foo and $bar  were interpolated into  $x, they
> > were not interpolated into $y.  It would be nice to get Success! from:
>
> Um, what would your proposal gain you over
>
>   $z = eval "qq{$y}";
>
> other than conciseness, elegance and speed (which may be quite enough!) ?

Correctness.  Your solution fails if $y contains '}' characters.  This was
noted in the next version, which I froze.  The cost of prechecking to choose
an appropriate delimiter, which if $y contains at least one instance of all
legal characters may not even exist, could be enormous (compared to the cost
of the operation) and unsuccessful.

That said, your solution works if the set of possible content of $y is
sufficiently constrained.

--
Glenn
=====
Even if you're on the right track,
you'll get run over if you just sit there.
                       -- Will Rogers


_______________________________________________
Why pay for something you could get for free?
NetZero provides FREE Internet Access and Email
http://www.netzero.net/download/index.html

Reply via email to