Dr.Ruud wrote:
Manfred Lotz schreef:

I like to specify a raw string, like for example $w:

my $who = "my friend";
my $w = q(This is \n $who.);


Now I want to evaluate that raw string so that the result is a string:
This is
my friend.


eval doesn't seem to help.


Actually I want to be able to specify a raw string where at the end of
the day only variables get expanded.


Any idea how to do this?

This is an X-Y question. ("How do I X with Y?")

That is a bad question format. A good question format is "How do I X?".

Now tell us a bit more about what you want to achieve and about its
environment.
Maybe you need a closure, or even just a sprintf, to do it properly.


Well, you are right. I was not very specific. Sorry about that.


What I actually want is to write a script where I call system commands which I want to specify as strings and I don't want to escape backslashes etc in the command string. That's why q() would be fine.

On the other hand I like to have Perl variables in the command string which I want to have evaluated before issuing the system command. Which makes q() a nogo.


Example:

my $DRYRUN="--dry-run";
my $cmd = q(rsync $DRYRUN -avh \
                 -exclude bla1  \
                 -exclude bla2  \
                 src tgtdir
};


system($cmd);


I would be happy if all occurences of simple vars ($v, $a_b etc.) would be evaluated. More complex stuff like $h{$key} would be nice but isn't really that important to have.


--
Thanks,
Manfred


.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to