The Ghost am Freitag, 13. Januar 2006 21.23:
> I know I could do that, but what if I don't know the variable names
> in the string?
>
> > $sql=~s/\$Status/$Status/;
>
> could I do:
> $sql=~s/\$(\S+)/${$1}/;
>
> On Jan 10, 2006, at 5:57 PM, John Doe wrote:
> > The Ghost am Dienstag, 10. Januar 2006 21.57:
> >> I want to pull some text from a database:
> >>
> >> RxNumber in (select RxNumber FROM restoreReports WHERE Status in
> >> $Status)
> >>
> >> then I want perl to use this string and interpolate the variables
> >> ($Status).
> >>
> >> so:
> >>
> >> my $Status= "('New','Old')";
> >> my $sql=get_SQL_String(); #will get 'RxNumber in (select RxNumber
> >> FROM restoreReports WHERE Status in $Status)'
> >
> > $sql=~s/\$Status/$Status/;
> >
> > (first time as literal string, second time as perl variable defined
> > in the
> > surrounding context)
> >
> > see
> >
> > perldoc perlre
> >
> >> print $sql;
> >>
> >> # should print:
> >>
> >> RxNumber in (select RxNumber FROM restoreReports WHERE Status in
> >> ('New','Old'))
> >>
> >>
> >> What can I do?

Could you reformulate your (top posted) question?
What do you mean exactly by "not knowing the variable names in the string?"
- $Status (chars in the string) and/or 
- Status (mysql) and/or 
- $Status (in the perl code)?


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


Reply via email to