Include files in PERL

Gidday from downunder,

When writing PHP if I want to an include I type include("filename.php");

Is there a similar command in PERL, does require do the job? In my mailing list application I re-use numerous functions and would like to pop these in a function library and include them on every page.

Colin Johnstone 
Website Project Officer
NSW Department of Education and Training 
0
Colin
11/6/2002 3:16:59 AM
perl.beginners 29388 articles. 4 followers. Follow

3 Replies
5912 Views

Similar Articles

[PageSpeed] 15
Get it on Google Play
Get it on Apple App Store

I think 'use' is what you're looking for.  But just in case,

perldoc -f require
perldoc -f use
perldoc perlmod

On the last one, I would recommend reading the first section and then
skipping down to the "Perl Modules" section.  Then you can go back over the
whole thing.  Just to give you a taste of how modules work, here's a sample
...pm file.  Don't forget the 1 at the end.

#################################
#  Sample.pm

package Tim::Sample; #assumes the file is at .../site/lib/Tim/

sub InsertSpaces{
  my @text = split //,$_[0]; #get characters of function parameter
  return join(' ',@text);    #return string made of chars w/spaces between
}

1
#################################

#################################
#  Sample.pl

use strict;
use warnings;
use Tim::Sample;

my $text = Tim::Sample::InsertSpaces("Hello World!");
print $text;

#################################

This prints "H e l l o  W o r l d !".
-----Original Message-----
From: Johnstone, Colin [mailto:Colin.Johnstone@det.nsw.edu.au]
Sent: Tuesday, November 05, 2002 7:17 PM
To: 'beginners@perl.org'
Subject: Include files in PERL


Gidday from downunder,

When writing PHP if I want to an include I type include("filename.php");

Is there a similar command in PERL, does require do the job? In my mailing
list application I re-use numerous functions and would like to pop these in
a function library and include them on every page.

Colin Johnstone 
Website Project Officer
NSW Department of Education and Training 

-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
0
tjohnson
11/6/2002 3:47:04 AM
Thanks Tim,

I'll give it a whirl.

Colin

-----Original Message-----
From: Timothy Johnson [mailto:tjohnson@sandisk.com]
Sent: Wednesday, November 06, 2002 14:47
To: Johnstone, Colin; 'beginners@perl.org'
Subject: RE: Include files in PERL



I think 'use' is what you're looking for.  But just in case,

perldoc -f require
perldoc -f use
perldoc perlmod

On the last one, I would recommend reading the first section and then
skipping down to the "Perl Modules" section.  Then you can go back over the
whole thing.  Just to give you a taste of how modules work, here's a sample
....pm file.  Don't forget the 1 at the end.

#################################
#  Sample.pm

package Tim::Sample; #assumes the file is at .../site/lib/Tim/

sub InsertSpaces{
  my @text = split //,$_[0]; #get characters of function parameter
  return join(' ',@text);    #return string made of chars w/spaces between
}

1
#################################

#################################
#  Sample.pl

use strict;
use warnings;
use Tim::Sample;

my $text = Tim::Sample::InsertSpaces("Hello World!");
print $text;

#################################

This prints "H e l l o  W o r l d !".
-----Original Message-----
From: Johnstone, Colin [mailto:Colin.Johnstone@det.nsw.edu.au]
Sent: Tuesday, November 05, 2002 7:17 PM
To: 'beginners@perl.org'
Subject: Include files in PERL


Gidday from downunder,

When writing PHP if I want to an include I type include("filename.php");

Is there a similar command in PERL, does require do the job? In my mailing
list application I re-use numerous functions and would like to pop these in
a function library and include them on every page.

Colin Johnstone 
Website Project Officer
NSW Department of Education and Training 

-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org

-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
0
Colin
11/6/2002 3:58:48 AM
Yeah this will sure do the trick but just in case you need another option to
do the same , "require" is also there to the rescue.

Just put all the functions you require in a separate .pl file.

The following solution can also be implemented as :

#################################
#  Sample.pl

sub InsertSpaces{
  my @text = split //,$_[0]; #get characters of function parameter
  return join(' ',@text);    #return string made of chars w/spaces between
}

1; # required so that file can be correctly included in another script 
   #- gives a 'true' response when loaded
#################################

#################################
#  RequireSample.pl

use strict;
use warnings;

require 'C:\WINNT\Profiles\athind\Desktop\Sample.pl'; #location of the perl
file acting as a repository of all the functions 

my $text = InsertSpaces("Hello World!");
print $text;

#################################

This prints "H e l l o  W o r l d !" too.

Take your pick :)

Thanks
Aman

-----Original Message-----
From: Timothy Johnson [mailto:tjohnson@sandisk.com]
Sent: Wednesday, November 06, 2002 9:17 AM
To: 'Johnstone, Colin'; 'beginners@perl.org'
Subject: RE: Include files in PERL



I think 'use' is what you're looking for.  But just in case,

perldoc -f require
perldoc -f use
perldoc perlmod

On the last one, I would recommend reading the first section and then
skipping down to the "Perl Modules" section.  Then you can go back over the
whole thing.  Just to give you a taste of how modules work, here's a sample
....pm file.  Don't forget the 1 at the end.

#################################
#  Sample.pm

package Tim::Sample; #assumes the file is at .../site/lib/Tim/

sub InsertSpaces{
  my @text = split //,$_[0]; #get characters of function parameter
  return join(' ',@text);    #return string made of chars w/spaces between
}

1
#################################

#################################
#  Sample.pl

use strict;
use warnings;
use Tim::Sample;

my $text = Tim::Sample::InsertSpaces("Hello World!");
print $text;

#################################

This prints "H e l l o  W o r l d !".
-----Original Message-----
From: Johnstone, Colin [mailto:Colin.Johnstone@det.nsw.edu.au]
Sent: Tuesday, November 05, 2002 7:17 PM
To: 'beginners@perl.org'
Subject: Include files in PERL


Gidday from downunder,

When writing PHP if I want to an include I type include("filename.php");

Is there a similar command in PERL, does require do the job? In my mailing
list application I re-use numerous functions and would like to pop these in
a function library and include them on every page.

Colin Johnstone 
Website Project Officer
NSW Department of Education and Training 

-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org

-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
0
AThind
11/6/2002 7:46:11 AM
Reply:

Similar Artilces:

How to Include File in aspx file
I am trying to convert asp code to aspx however I do not know how to include file in aspx code. Can you please provide me very simple code which will include file. e.g. <!--#include virtual ="/files/includes/header.asp" --> in asp...How do I achieve this ?Thanks Please check the following article: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306575&ID=kb;en-us;Q306575&SD=MSDN http://www.dotnetextreme.com/code/PageLetControls.asp In .NET you have a web user control with an extension .ascx. You can convert the code in your asp ...

How to Include File in ASCX file
hi alli have 10 skins in one portal i wnat to include same file in all of them so if i change this file it take effect in all my skins thanks yaron You'll need to make that ASCX file a Skin Object in the module definitions under host settings. Once you do that you can add that skin object to your skin files. Similiar to the way you add the SolPartMenu [menu] to your skins.ChrisHammond.comEngage Software You can place the style in _default portal css files. and use that style for CssClass.After that you may use this style in as many child skin as you need. But there is no automation t...

Including a file in codebehind file
I have project that has all it's files currently using inline code.  As a result, there are alot of files where headers and included using <!-- #include file="" --> There is one page, a module that is included in many other pages, where I am trying to convert to use code behind.  I am trying to do this with VS and just manually compiling the code behind file. However, this file depends on many other includes from other files.  I was wondering how I can accomplish this, as it seems as using includes in codebehind doesn't work. Depending on the ...

superreview granted: [Bug 180316] some files have too many #includes (not relevant to file) : [Attachment 128006] fix some includes in editor/idl
<tor@acm.org> has granted brade@comcast.net's request for superreview: Bug 180316: some files have too many #includes (not relevant to file) http://bugzilla.mozilla.org/show_bug.cgi?id=180316 Attachment 128006: fix some includes in editor/idl http://bugzilla.mozilla.org/attachment.cgi?id=128006&action=edit ...

superreview granted: [Bug 180316] some files have too many #includes (not relevant to file) : [Attachment 127314] include cleanup for composer/src
Darin Fisher <darin@meer.net> has granted brade@netscape.com's request for superreview: Bug 180316: some files have too many #includes (not relevant to file) http://bugzilla.mozilla.org/show_bug.cgi?id=180316 Attachment 127314: include cleanup for composer/src http://bugzilla.mozilla.org/attachment.cgi?id=127314&action=edit ------- Additional Comments from Darin Fisher <darin@meer.net> sr=darin ...

superreview requested: [Bug 180316] some files have too many #includes (not relevant to file) : [Attachment 128006] fix some includes in editor/idl
<brade@comcast.net> has asked tor@acm.org for superreview: Bug 180316: some files have too many #includes (not relevant to file) http://bugzilla.mozilla.org/show_bug.cgi?id=180316 Attachment 128006: fix some includes in editor/idl http://bugzilla.mozilla.org/attachment.cgi?id=128006&action=edit ...

superreview requested: [Bug 180316] some files have too many #includes (not relevant to file) : [Attachment 127314] include cleanup for composer/src
<brade@netscape.com> has asked kin@netscape.com for superreview: Bug 180316: some files have too many #includes (not relevant to file) http://bugzilla.mozilla.org/show_bug.cgi?id=180316 Attachment 127314: include cleanup for composer/src http://bugzilla.mozilla.org/attachment.cgi?id=127314&action=edit ...

include files and aspx.vb files
 I've been using include files for years for asp, so have a core of several that do the dim declarations, set up the database stuff, handle error reporting etc.Since I'm starting to use .net and want to use codebehind, I'm trying to figure how to do the very basic parts like have my dims.inc and dbopen.inc files used by the aspx.vb files.In the process of building the .net version of a small asp project, I tried to include my normal set of .inc files, and the frist error suggests that the dim statements have been ignored and the first variable found throws the 'declarati...

How do I include an ASPX file in a HTML file
My organisation has a large web site using HTML templates containing headers, footers, search, navigation and a content section. I have built a form using ASP.Net C# and I need to include it into the HTML templated page where the content would go. A Include ststement does not appear to work.Apart from changing the site to ASP.Net and using a user control what is the quickest solution? Glenn Your web server will need to support ASP.NET. Because HTML files are rendered as static content, you will not be able to use .aspx files as part of the HTML file. You will need to use an iFrame or frame...

how to include another file in *.vb file?
in class asp programme,i can use <!-- #include file=filename --> while using code-behind programming , some shared functions were wrote in one file, how to include this file in *.vb file You can create the code, compile it and place the DLL in the bin folder.Starting with ASP.NET 2.0? Look at:Programming Microsoft Web Forms My Blog...

including JS file in ascx file
formore then a day i try to include JS file in one of my user controls... i tried: <script src="myjs.js"></script>, anf tried to move the file to the same folde, to another folder, i used "~/foldder/mujs.js"and more and more... i allways get the same error- object required.... does it possible to include the JS file in the html of ascx file? if yes, how i do it? i justcan't find the way.... hi yani, its working here my side with following syntax <script language="javascript" type="text/javascript" src="sourcing.js" ></script> thanks, satish.Kind Attn: If a re...

How to include a file into another aspx file
Can someone please help me: I'm looking for a similar function in aspx to the "include" function in PHP. for example, I need a function that lets me include a single menu.aspx file in every page I have in my site. Is there something like that?   Thanks   Nope, and that always was a nasty way of re-using code.Look at Master Pages and Web Controls.  Create the menu as a web control and place that control on every page, or use a master page with an embedded menu.  User Web Controls :)Domain Names | ASP.NET 3.5 Hosting - $3.99/mo (10 GB Space, 300 ...

How to include an aspx-file in an aspx-file?
Hello, I have an ASP.NET page ("Kalender.aspx") where I would like to include another ASP.NET page ("MyCalendar.aspx"), so far I couldn't find the solution... 8{ This is the code of "Kalender.aspx" : ------------------------------------------------------------------------------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>zjaak</title> </head> <body> <table height="377" cellspacing="0" cellp...

Include a .JS file into a .JS file
Hi,   Its very simple as below.   For example, Requirement is to add reference in File1.js to File2.js.   document.write("<script type='text/javascript' src='../JS/File2.js'></script>");  All you need to take care is, the source path must be relative to the Page, rather than to the File1.js    Thanks & Regards, Arun Manglick || Senior Tech Lead || http://arun-ts.blogspot.com/  Arun Manglick  Can it not be done like this :include('myFile1.js');  inclu...

Including a .ico file in a .pbr file
I have an application whose icon is not showing up in the splash screen. We have a set of applications, all of which use a .pbr file to display their icons. I don't know how the .pbr file was created, but I'm guessing that for this more recent application, the .ico file has not been included. How do I get the new .ico file included in my resource file? Just add the .ico filename in the resource file (.pbr). Use the exact name including path as specified in the application. You can edit the pbr file using a regular text editor or using the text editor included in ...

Web resources about - Include files in PERL - perl.beginners

Wikipedia talk:Do not include the full text of lengthy primary sources - Wikipedia, the free encyclopedia ...
"Do not include copies of primary sources (specifically: text, maps, artworks and other useful images) in Wikipedia. If it is a large source, ...

Bing Redesign Includes Social Sidebar Column With More Facebook Integration
Microsoft introduced an update to its Bing search engine today that includes a sidebar column containing related information from users’ Facebook ...

Travis Kalanick - I thought I'd include a FB post I just... - Facebook
I thought I'd include a FB post I just did responding to a concern that Uber's SF service was decreasing in quality. _________________________ Hey... ...

Facebook News Feed changes include improvements for app developers
... is how much bigger stories and photos appear in the feed. The example below is full size. Then there’s the redesigned games feed, which includes ...

Mick Fanning shark attack: WSL includes J-Bay Open on 2016 schedule
AUSSIE surfer Mick Fanning will have to face his fears and return to the place he was attacked by a shark after the World Surf League chose to ...

Conversations about autism need to include people like me
Unfortunately the conversation about autism has so far been at the expense of autistic people. The voices of autistic people must be heard. ...

Steroid dealer says users include firefighters, moms, teens, 'elite' hockey players
In 'Cheating The Game', a co-production by TSN and CTV airing on SportsCentre on Friday and W5 on Saturday, TSN Senior Correspondent Rick Westhead ...

ASUS Launches Maximus VIII Extreme/Assembly for Skylake, includes 10G Ethernet Card
... card line and the new color scheme for their latest Matrix GTX 980 Ti. The interesting part from this launch comes in the bundle, which includes ...

Overstock’s Black Friday 2015 ad includes some great gaming, electronics deals
Just when you thought the last of the Black Friday 2015 ads might have finally leaked, there's something new to peruse. On Monday, we got a glimpse ...

EPA Expands VW Diesel Probe to Include More 3.0-Liter Models
... The U.S. Environmental Protection Agency and the California Air Resources Board said Friday that the investigation has been expanded to include ...

Resources last updated: 11/22/2015 5:45:01 AM