Inserting perl code into a file

G

Gary Mayor

Hi,
I'm trying to insert some perl code into another file. If I use

$code = qq{
$a = "1";
if ($a eq "1") {print "A = 1";}
};
open(FILE,">runme.cgi");
print FILE $code;
close FILE;

It just says syntax error at the end of the file. I've tried escaping
the $ with \$ but that didn't work. Does anyone know how to do this?

Thanks

Gary Mayor
 
T

Tad McClellan

Gary Mayor said:
I'm trying to insert some perl code into another file. If I use

$code = qq{

It just says syntax error at the end of the file.


It said more than that when you enabled warnings.

You should always enable warnings when developing Perl code!

Does anyone know how to do this?


Yes.

Delete one "q" character.
 
G

Gunnar Hjalmarsson

Gary said:
I'm trying to insert some perl code into another file. If I use

$code = qq{
$a = "1";
if ($a eq "1") {print "A = 1";}
};
open(FILE,">runme.cgi");
print FILE $code;
close FILE;

It just says syntax error at the end of the file. I've tried
escaping the $ with \$ but that didn't work.

Then try harder, because it should.

Alternatively you can replace the qq// operator with the q// ditto.
 
G

Gary Mayor

Sorry everyone it was a late night that wasn't the problem it was a
missing }. Darn...... Thanks anyway
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top