image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #9  
Old June 18th, 2006, 04:16 PM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
snydersoft is on a distinguished road
Cool

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.
Reply With Quote
  #10  
Old March 11th, 2008, 04:49 PM
Registered User
 
Join Date: Mar 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
SeniorSE is on a distinguished road
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;
newsub.pm
Code:
#!/usr/bin/perl

sub newsub {

print "hello\n";

}

return 1;
exit;
And, make sure that the newsub.pm file is in the same directory as the perl script you are running it with. optionally, you can figure out how to add it to your perllocal.pod config file, so it will be global to your perl installation. (I don't know how to do that, though. )

Good luck,
Mark
Reply With Quote
  #11  
Old June 30th, 2008, 05:05 PM
Registered User
 
Join Date: Jun 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ravipatel4 is on a distinguished road
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
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 Off
Pingbacks are Off
Refbacks are Off
Forum Jump

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


All times are GMT -5. The time now is 05:37 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.