in reply to Trying to understand some body's old code.

Well, it wouldn't work for things other than scalars. To make it work, change it to:

s/(\$[\w\[\]{}']+)/$1/gee;
It wouldn't work because ${array[0]} isn't the same as $array[0]. This is a bit dangerous and still won't handle all cases.

Update: Well, ${array[0]} actually is the same as $array[0]. My replacement also works OK, but they both fail for strings like q(${name}'s).

Update: I was thinking that the FAQ had a method using eval which is pretty dangerous. I checked and that was mentioned in a post here, not in the FAQ. But that method has another problem in that it is hard to pick a delimiter to use in eval '"'.$str.'"' (since $str might contain a " or any other delimiter you pick).

Well, it appears that my solution comes close to dealing with these problems, so I made it more robust:

s/(\$[\w\[\]{}']+)/'"'.$1.'"'/gee;
Note that I won't certify this as "safe" because I'm not convinced that someone more clever than I can't come up with a string that would do bad things like reboot your computer (like ${[system'shutdown']} or ${\qx'shutdown'} almost do) or just that fails to be interpretted properly.

        - tye (but my friends call me "Tye")