On Sun, 24 Dec 2000, craig duncan wrote:

> In some of the previous "Hash access method" threads i've seen this sort
> of thing:
> 
> a = "#{b}"
> 
> to assign the value of the variable b to a.  My understanding is that
> `#{var}' is string interpolation and that this would be a rather
> indirect way of getting the value of `b'.  The doc. seems to say that
> string interpolation works by eval'ing the variable, so the direct (and
> equivalent) way of doing this would be:
> 
> a = eval 'b'
> 
> Is this, in fact, the case?  Are they exactly equivalent?  And therefore
> eval is to be preferred in this instance?

No, no, and no.  (In that order :-)

See Dave T.'s post.  The only thing I wanted to add was that the
string interpolation operator #{} can operate on anything, not just a
lone variable:

   b = 100
   a = "Fahrenheit equivalent of #{b}: #{b * 9 / 5 + 32} degrees."
     ==>"Fahrenheit equivalent of 100: 212 degrees."

Not that there was anything in your post which specifically suggested
lack of knowledge of this -- but since the example was simple, and you
were describing it in terms of the single variable, I wasn't sure
whether the versatility of #{} was clear.  (And anyway, it'll be
welcome news to one or two Perl-experienced nubies out there :-)


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav