On Thu, 30 Jan 2003, Wizard wrote:
> Why isn't this working (I'm know that I've used it before):
> =========================================================
> #!/usr/bin/perl -Tw
>
> my $string = "This is a PERL_FDATA_tieval for testing";
> my $tieval = "String";
>
> # $string =~ s/PERL_FDATA_([a-zA-Z]+)/$$1/i;
> $string =~ s/PERL_FDATA_([a-zA-Z]+)//i;
> print "\$$1 = $$1\n\$tieval = $tieval\n";
> # print "$string\n"
> =========================================================
>
> I am trying to replace the 'PERL_FDATA_tieval' with the value for $tieval,
> but although the $1 appears to interpolate correctly, the $$1 doesn't. I've
> tried:
> $$1
> ${$1}
> ${ "$1" }
>
> I've even passed it as a list argument in print() like so:
> print "\$$1 = ", $$1, "\n";
> but that doesn't seem to work either.
> Any Help?
> Grant M.
You could put your data to be interpolated into a hash with appropriate
keys which makes life easier (or so it seems to me.) Otherwise one way
to do it is
$string =~ s/PERL_FDATA_([a-zA-Z]+)/'$' . $1/ee;
Hope this helps,
Mike
--
[EMAIL PROTECTED] | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA
[EMAIL PROTECTED] | Fingerprint 0570 71CD 6790 7C28 3D60
http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm