Re: Here document construct problem
by kutsu (Priest) on Feb 17, 2005 at 20:37 UTC
|
As I pointed out in the CB both the here docs and qq or q work for me; so the error is either somewhere else or you forgot to end a HERE doc somewhere. my test case:
Judging by the amount of HTML your printing using HERE docs in your code, you might want to look at HTML::Template. Which would allow you to seperate your HTML and perl code (which is much easier to debug and update).
"Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce
| [reply] [d/l] |
|
I have actually already begun the tedius process of replacing the here document constructs with q() in all of my scripts. I was just wondering why in this particular script I was running into probs. With regard to your testing i can narrow the entire script down to just that block I showed before and the basic HTML tags and I still get warnings. I looked at the HTML::Template, and would surely use it if I could. I only have two weeks left on the project, and I need to get all 70 + scripts updated to DBI and CGI::simple first. I am currently in the process of adding "use strict" and "use warnings" to every script which is how I ran into this problem in the first place.
Thanks for all your time,
hok_si_la
| [reply] |
Re: Here document construct problem
by artist (Parson) on Feb 17, 2005 at 20:34 UTC
|
"Original Script" has an extra space character at the end (after END_OF_PRINT). Remove that character and it should work fine.
| [reply] |
|
Artist,
I removed the trailing spaces, and I am still getting the warning. I will update my scratchpad with the new code.
hok_si_la
| [reply] |
|
Can you run this code (via the shell/Command Prompt/Run)
perl -nle "print qq(Check line: $.), if (m/print <<ENDOFHTML;\s+$/ or (m/^(\s*)ENDOFHTML(\s*)$/ and ($1 or $2)))" filename
| [reply] [d/l] |
Re: Here document construct problem
by Animator (Hermit) on Feb 17, 2005 at 20:41 UTC
|
Are you sure $data is defined? and all elements in data? Have you tried dumping the %data-hash (using Data::Dumper)?
The code in your scratchpad does not show the definition of %data...
| [reply] |
|
Animator,
Data and all of its elements seem to be defined. The script spits them out as it should with the one exception being the table row that prints out the warnings, which actually changes from query to query. I have not tried data dumper yet. I can comment out the subroutine call altogether and still have issues, so that shouldn't be it. At this point I am not really one to say though so I will give it a try.
hok_si_la
| [reply] |
Re: Here document construct problem
by thedoe (Monk) on Feb 17, 2005 at 21:09 UTC
|
What is the full source code? Just by using your scratchpad it is not possible to examine the line of code actually generating the warning.
When using warnings, perl generates this warning when it tries to evaluate a variable that has not been previously defined. Try looking at line 349 in your code and what variables are being used in it. If there are multiple variables used, use the process of elimination to figure out which is causing your problem, then make sure to assign it the value you need.
Update: Changed using strict to using warnings to correct mix-up.
| [reply] |
|
thedoe,
Using strict doesn't cause the warnings. Usings warnings does. If I comment out "use warnings;" I have no prob. The line that the warning is referring to is the middle END_OF_PRINT from the block of code that I posted. This block is encased by "&*&*&*&*&*&*&" in my scratchpad. I will comment the line itself.
hok_si_la
| [reply] |
|
I apologize for my previous mixup of use strict and use warnings.
As for where the warnings are coming from, they are being generated by variables within the here document starting at line 349. Any variables inside which have not been previously assigned will give you this warning and report line 349. This includes any keys in the data hash which have not been previously assigned, even if the data hash has been created.
A good way to debug it would be using Data::Dumper as previously suggested for the data hash and manually inspecting any other variables used within that here document.
| [reply] |
|
|
|
END_OF_PRINT
#&printOwner($data{owner1});
#&printOwner($data{owner2});
#&printOwner($data{owner3});
print <<END_OF_PRINT;
</TH>
</TR>
END_OF_PRINT
is changed to:
#END_OF_PRINT
#&printOwner($data{owner1});
#&printOwner($data{owner2});
#&printOwner($data{owner3});
#print <<END_OF_PRINT;
</TH>
</TR>
and picked up by the END_OF_PRINT that occurs after <html> ?
Update: Ok. Just checking for any weirdness in slight deviations from what you posted above. Ignore my comments below this reply, for they were added in error.
/renz.
"This is the Mark-man, safe and sure,
Who still is right, and prayes to be so still."
--George Herbert, Constancie.
| [reply] [d/l] [select] |
|