[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Greenhorn coding question



Thanks to all and sorry for the inappropriate posting.

On Tue, 6 Jul 1999, Brand Hilton wrote:

> In fact, this is exactly the point being made in that entry of
> perlfaq4.  Quoting:
> 
>      How can I expand variables in text strings?
> 
>      Let's assume that you have a string like:
> 
>          $text = 'this has a $foo in it and a $bar';
> 
>      If those were both global variables, then this would
>      suffice:

I must have an old faq (RHL 5.2) or I'd have seen this and done more
research.

> 
>          $text =~ s/\$(\w+)/${$1}/g;  # no /e needed
> 
>      But since they are probably lexicals, or at least, they
>      could be, you'd have to do this:
> 
>          $text =~ s/(\$\w+)/$1/eeg;
>          die if $@;                  # needed /ee, not /e
> 
> ==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
> ==== Send email to <fwp-request@technofile.org> with message _body_
> ====   unsubscribe
> 

--
Roderick A. Anderson
raanders@altoplanos.net               Altoplanos Information Systems, Inc.
Voice: 208.765.6149                            212 S. 11th Street, Suite 5
FAX: 208.664.5299                                  Coeur d'Alene, ID 83814


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe