On 24 Sep 2003 at 15:20, Dave Hinton wrote:

> On Wednesday, September 24, 2003, at 03:04 pm, Simon Wistow wrote:
> 
> > you could do something like
> >
> >     my $data = join "", <DATA>;
> >     eval "\$date = \"$data\";";
> >
> > which is icky but works
> 
> Doesn't work when $data contains any double quotes.

I think Brian McCauley(sp?) has a solution to this (that he wanted to 
get into the Perl FAQ) using here-docs. Something like this:

    my $data = join '', <DATA>;
    eval "\$data = <<UNLIKELYSTRING;\n$data\nUNLIKELYSTRING";

Now single and double quotes are both allowed and variables are 
interpolated. And "UNLIKELYSTRING" (or whatever you choose as a 
terminator) is, presumably, less likely to occur than a single double 
quote.

Cheers,
Philip
-- 
Philip Newton <[EMAIL PROTECTED]>


Reply via email to