"Balint, Jess" <[EMAIL PROTECTED]> writes:

> Hello all. I am getting an error with the following reg-exp:
> 
>       s/\$\{(\w+)\}/$$1/g;
> 
> I am not sure exactly how to do this type of thing. Is there any way to get
> around the error or must I turn off 'strict refs' for this line?? Thanks
> alot.

I'm not exactly sure what you are trying to do here - if my suggestion
isn't what you want, please give a better description of what you want
- It looks like you want to change: '${bar}' into '$bar', so - just
escape the first '$' in the substitution part of your regexp:

#!/usr/bin/perl -lw #the 'l' adds a newline to the end of any 'print'

my $foo = '${bar}';
print $foo; 
$foo =~ s/\$\{(\w+)\}/\$$1/g;
print $foo;


OUTPUT - 

${bar}
$bar


You are getting the warning becuase $$1 is an attempt to dereference
a scalar reference called '$1'.

-RN

-- 

Robin Norwood
Red Hat, Inc.

"The Sage does nothing, yet nothing remains undone."
-Lao Tzu, Te Tao Ching

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to