MichaelBluejay

msg:3179959 | 1:17 pm on Dec 6, 2006 (gmt 0) |
The error message is pretty clear: You have an unmatched ) symbol. You have to have the same number of open & close parentheses. Now, I have no idea what the line in question is supposed to do, so I don't know how to balance it. Did you copy & paste it from somewhere, or did you write it yourself? If the latter, what exactly is it supposed to do? The =~ s/// syntax is for replacing some characters with other characters, but I'm a bit sleepy to try to interpret this particular use of it.
|
dawlish

msg:3180149 | 4:00 pm on Dec 6, 2006 (gmt 0) |
Thanks for the reply. I copy and pasted the line which was recommended by someone else. $formTemplate=~s/$include[([^]]+)]/qx(cat ""$1"")/ge; However this is the line were the problem is with error: Unmatched ) in regex; marked by <-- HERE in m/[([^]]+) <-- HERE ]/ at data.pl line 259. Essentially, I have a content management system for my site which was developed by someone else as my programming skills are limited. I'm a designer. The addition of the line of code is to enable me to use $include[whateverfilename.html] in the site templates. The effect would be to act like a server side include and enable me to use a header and footer html file. For instance where ever i entered $include[header.htm] in the website templates, the content of header.htm would be included. I can see the error is suggesting I'm missing a )but can't work out how to fix it.
|
perl_diver

msg:3180422 | 6:48 pm on Dec 6, 2006 (gmt 0) |
this: $include[([^]]+)] should be: $include[([^\]]+)] the ']' is obviously a special character, it's the end of the character class. Adding the \ escapes it so perl treats it literally. But shelling out to open the file qx(cat ""$1"") could probably be done in a better way using perls open() function. Using the shell is not efficient and certainly not portable. Write a sub rotuine that opens and prints the file or stores the file in a variable for printing later. $formTemplate=~s/$include[([^\]]+)]/go_get($1)/ge; sub go_get { my $file = shift ¦¦ return 0; open(FH,$file) or die "Can't open $file: $!"; print <FH>; close FH; } but really you may want to look into HTML::Template or other templating system.
|
perl_diver

msg:3180428 | 6:52 pm on Dec 6, 2006 (gmt 0) |
I jumped the gun, this: $formTemplate=~s/$include[([^]]+)]/qx(cat ""$1"")/ge; should be: $formTemplate=~s/$include\[([^\]]+)\]/go_get($1)/ge; even better would be to change your delimiters from [] to something else, maybe: $include%%filenme%% s/$include%%([^%])%%/go_get($1)/ge; this avoids interpolation by perl of the meta characters: []
|
dawlish

msg:3181265 | 12:34 pm on Dec 7, 2006 (gmt 0) |
Many thanks perl_diver. I've now got it to work. Could you offer any advice as to how I can modify the script to include the output of a cgi script. At the moment I can only include a file. I want to include a banner rotate script at the top of my site. Ideally use $include%%/cgi-bin/banner.cgi?type=plants%% I know that I'll need use LWP::Simple; at the top of the script but don't know how to change s/$include%%([^%])%%/go_get($1)/ge;
|
|