Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Inserting perl code into a file

Reply
Thread Tools

Inserting perl code into a file

 
 
Gary Mayor
Guest
Posts: n/a
 
      01-01-2004
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

 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      01-02-2004
Gary Mayor <(E-Mail Removed)> wrote:

> 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.


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      01-02-2004
Gary Mayor wrote:
> 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.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 
Reply With Quote
 
Gary Mayor
Guest
Posts: n/a
 
      01-02-2004
Sorry everyone it was a late night that wasn't the problem it was a
missing }. Darn...... Thanks anyway


Gary Mayor wrote:
> 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
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Whats wrong with this code (inserting elements into std::map) Ian Collins C++ 3 01-19-2009 10:41 PM
Inserting text into a HTML file using Perl Slain Perl Misc 1 05-18-2007 03:39 PM
Perl open(). Inserting data into a file dshan@web.de Perl Misc 2 12-07-2004 02:53 PM
Programmatically inserting controls into old legacy Response.Write style code Benjamin Joldersma ASP .Net Building Controls 0 05-13-2004 06:41 PM
Way to loop code for inserting Checkboxlist values into DB? wjer ASP .Net 0 02-13-2004 08:39 PM



Advertisments