in reply to Re: Double quoted string as method call
in thread Double quoted string as method call

UPDATE: Actually this compiles fine but doesn't actually work, see first response below for reason why. Thanks anyway.

---------- Old message ----------

Thank you!

I should note, however, that in my case this failed with a syntax error until I added a () to the end of the, as such:

$obj->${"text_${_}"}();

This may have to do with the particulars of my code.

(As for the DBI call, that stuff can safely be ignored. I would note it was actually flawed insofar as I tried to pass in taint information incorrectly, the correct parameter order is dsn, user, pass, then a hashref with other optional config info, which I usually compose as {Taint=>1}.)

Replies are listed 'Best First'.
Re: Re: Re: Double quoted string as method call
by dave_the_m (Monsignor) on May 04, 2004 at 22:40 UTC
    $obj->${"text_${_}"}();
    I don't think that does what you want it to: it does one too many levels of indirection. if $_ has the value "foo", then I presume you want to do the equivalent of
    $obj->text_foo()
    In fact, supposing you have a variable called $text_foo with value bar, then what you are actually doing is the equivalent of
    $obj->bar()

      You're right -- this doesn't do what I thought. In fact, while it will compile, it doesn't actually work. :--(