[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Using << to make a long string



At 00:26 +0000 10.02.98, Jon Jacob wrote:
>I am creating a CGI and embed a javascript within my Perl code.  I want to
>set the javascript to a variable by the name of $script.  I run the
>following code:
>
>$script = <<EOS
>
><I put my javascript in here>
>
>EOS
>
>MacPerl gives my the following error:
>
># Can't find string terminator "EOS" anywhere before EOF.
>File '<AppleEvent>'; Line 22
>
>I have run the javascript on its own and it is errorfree, and I know that
>this syntax works on a UNIX box, although I have not had a chance to try
>this with my code specifically.  Is this a problem with MacPerl or am I
>missing something?
>

Jon,

At least in your example above you forgot something: the semicolon after
the statement

	$script = <<EOS

that is you coded shell syntax while perl expects

	$script = <<EOS;

Hope this helps.

	--jc

P.S. BTW: while I'm quite comfortable with here documents, I most often
prefer to put longer text segments after the __END__ maker instead and at
the start of my scripts I parse that data into an array, with e.g.

%HERE = ();

my $key = 'default';
while ( <DATA> ) {
  if ( /^%%here:\s*(.*)/ {
    ($key) = $1;
    next;
  }
    $HERE{$key} .= $_;
}

That allows me to put my data into named data sections (each section starts
with something like "%%here: account-form-1" ) and then access it in my
scripts via $HERE{'account-form-1'}

Yes, I know that I have to do the variable interpolations myself then, but
that's fine with me as long as it's just a handful of variables.

--
JŸrgen Christoffel, GMD - Forschungszentrum Informationstechnik GmbH
E-Mail: christoffel@gmd.de or one of {ftp,news,web}master@gmd.de



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch