|
#9
| |||
| |||
| Obviously this thread is OLD and my assistance probably isn't needed. But I surfed to it while looking for something else and who knows...maybe someone else will so I am going to add my thoughts on the matter in case it can help them out. As for the headers problem. While the text/html header was in the test file, you will notice that it wasn't in the settings file (the included file). The error received would suggest that the proper headings aren't being sent by the settings file so I would add the text/html header line to the included file. When including a file, the included file still processes whatever subroutine you call and then sends the result to the original file which places the result into it's own results in that place. Therefore since the settings file is trying to print text/html to the browser, the script isn't sending the proper headers to the browser to tell it what to expect. The settings file then sends the error to the main script. So the originating script doesn't have an error in it. Now, once this is taken care of (if that would actually fix the problem) you should also add the following..I am going to add it on its own line so you can see exactly what it is: 1; That should be the last line of ANY file that you include in any script. When you add a require the script is going to test the included file for a value. Adding that line will make the require a "true" statement and therefore allow it to run. Now the error that was received may suggest that that wasn't a problem. But it's safe practice to do so. Especially if a script is being programmed for use by many people on many systems. You want everything to be as portable as possible. Hopefully this will help someone out someday. |
|
#10
| |||
| |||
| How to include your own files into another perl Script I'm kind of new to perl, but I see an error in your code above and I know how to accomplish what you want. First, the hash-bang line needs to be the first line in the perl script (before the use command). Second, when using "use" or "require", it appears that the system does not want .pl extensions, but rather .pm extensions. So, if you have code that looks like this: prog.pl Code: #!/usr/bin/perl -w use newsub; &newsub; exit; Code: #!/usr/bin/perl
sub newsub {
print "hello\n";
}
return 1;
exit; )Good luck, Mark |
|
#11
| |||
| |||
| How to include your own files into another perl Script The problem of the header error is due to the wrong positions of lines. You need to add the header line first. Means put the line print "Content-type: text/html\n\n"; before the "require" statement. It will definitely solve your problem. contact me if you have any other problem. You can contact me at www.liveperson.com/ravi-patel Good luck. Bye Ravi Patel |
![]() |
| Thread Tools | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Example Perl script - FileMaker to MySQL migration generated by FmPro Migrator | dsimpson | Software Programming & Web Scripting | 0 | April 18th, 2003 04:24 PM |
| I installed Fink under root and..... | Hydroglow | Unix & X11 | 5 | November 27th, 2002 04:57 PM |
| HOW TO STOP SPAM -- join the fight! | GadgetLover | Apple News, Rumors & Discussion | 11 | April 11th, 2002 03:52 PM |
| vignette client on mac os x | erim | Software Programming & Web Scripting | 8 | July 13th, 2001 02:14 PM |
| perl problem - i cannot open a file for writing | level42 | Mac OS X System & Mac Software | 7 | June 10th, 2001 07:33 PM |