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

[MacPerl] Interesting problem



I just had an interesting problem occur which I thought I'd pass along.

I am writing some Perl scripts to handle the creation of web pages.  All
of these programs follow pretty much the same pattern.  That is:

	require "blah.pl";
	do "blah2.pl";
	do "blahwhatever.pl";

	$theReply = <<END_HTML;
<html>
<head>
<title></title>
</head>

<body>
END_HTML

	More code
	More of the $theReply .= <<END_HTML; stuff
	etc...

	print $theReply;
	exit( 0 );

Well, I got an error from the server saying there was an incorrect
header someplace in one of my programs.  I checked it out and sure
enough I had left off the first $theReply thing shown above so there
wasn't an "<html>" line etc....  So I fixed that.  Then the weirdness
started.  First, for some unknown reason, the program started losing the
incoming information.  (ie: The &myVar=1&yourVar=2... stuff.)  So I went
to look at that and could not find anything wrong with the code.  Then
that started working again but I started getting the incorrect header
message again.  So I decided to put a -d on the #!/perl line so I could
trace everything.  It said there was an error in the "require
"blah.pl";" area.  I checked it out but there wasn't anything wrong with
it.  This went on for hours.  Finally I tried stepping through the
MacPerl debugger to see if I could trace the problem.  Only with the
debugger going there wasn't any problem.  It worked fine.  But if I ran
it without the debugger it gave the error messages.

Ok, so after hours of aggravation I finally realized that somehow,
someway I'd managed to change all of the "$theReply .= <<END_HTML;"
stuff into "$addOn .= <<END_HTML;" statements.  After changing them back
the program worked ok.

Now, first off, I went back and forth between Linux and MacPerl on this
because it allowed me to trace the problem on two systems.  So this
isn't just a MacPerl problem.  But what I'm wondering about is why did
debug say the problem was at the top of the program when there really
wasn't a problem at all with the code?  The problem was that I had a
different variable name used throughout the program and so the program
returned nothing.

Any ideas?  The thing is fixed and working properly, but I was wondering
if there is some sort of a reason why it did this.  Thanks!  :-)

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