in reply to problem in using eval strings

Might I recommend a different way to build up your string which may be a bit closer to what you're trying to accomplish? (I'm an advocate of making my solutions look like the problem, not like the solution.)

I'm assuming your "for loop" is using a list such as @args.

my $call = '$jobs->$func(' . join(', ', map qq{"$_"}, @args) . ')'; my %jobstats = eval $call;

I'm avoiding all the chops as I don't add more commas than needed. That said, even the way you're doing it, you could remove the chops - trailing commas don't bother perl at all. My guess is that perl would parse and discard the comma faster inside the compiler than by using chop anyway.

Anyway, this code builds your method call in exactly the same way that you normally do. You convert your arguments to be quoted (converting one list to another is a map), you put commas between them (putting a string - even if it were an empty string - repeatedly between other strings is a join), and you put stuff before and after (with the dot operator).

Using the escape (backslash) as has already been suggested is one way to do this when you need to use double quotes. But I find escapes to be distracting and like to avoid them when reasonably possible.

Belgarion is correct in what your problem is. I'm just offering another way to approach your basic problem that may prove better.

Note: Even better for this scenario is:

my %jobstats = $jobs->$func(@args);
There's no need, in this scenario, to use eval at all. But I'm presuming you have something that becomes a bit complex that you want to use eval for - such as @args having "$foo" as one of its values, and eval STRING will then see "$foo" and interpolate the $foo to be whatever $foo contains. Which is generally a bad idea when you can avoid it - use hashes.