Re: [OT] Perl: exec and $variables
On Sat, Jul 21, 2001 at 01:04:40PM +0200, Sven Burgener wrote:
> I have a problem with some perl code. I know this is off-topic, but
> there are numerous knowledgeable people on deb-usr, so forgive me for
> posting this.
>
> Now to my problem.
>
> Given the following variable,
>
> my $BEGINREGEX = "sprintf(\"^<!-- // begin of news\$no // !-->\$\")";
Please tell us what you're trying to accomplish first. It is unclear
what assumptions you are making.
> the following eval() call doesn't substitute $no for what it is and
> return the new string with the substituted $no in it:
>
> my $no = 1;
> my $bla = eval($BEGINREGEX);
> print "$bla\n";
>
> $bla is empty for some reason.
>
> So how would I go about having $no substituted in $BEGINREGEX for
> whatever it happens to be set to at a particular point in the script?
You probably do not want to use eval here, or at least not in this way.
Cheers,
Joost
Reply to: