Ask a Question related to PERL Beginners, Design and Development.
-
Mallik #1
Use and Require
Dear Perl Gurus,
What is the difference between Use and Require.
Thanks,
Malliks
Mallik Guest
-
require
hi i want to require or include a file in my php script. the file i want to include contains some variables and some normal html. i want to get... -
#25782 [Opn->Bgs]: require( 'require.php' ) crashing Apache 1.3.28
ID: 25782 Updated by: sniper@php.net Reported By: akinder at technology-x dot com -Status: Open +Status: ... -
#25782 [Fbk->Opn]: require( 'require.php' ) crashing Apache 1.3.28
ID: 25782 User updated by: akinder at technology-x dot com Reported By: akinder at technology-x dot com -Status: ... -
#25782 [Opn->Fbk]: require( 'require.php' ) crashing Apache 1.3.28
ID: 25782 Updated by: sniper@php.net Reported By: akinder at technology-x dot com -Status: Open +Status: ... -
#25782 [NEW]: require( 'require.php' ) crashing Apache 1.3.28
From: akinder at technology-x dot com Operating system: Linux RedHat 9 PHP version: 5.0.0b1 (beta1) PHP Bug Type: Apache... -
Rob Dixon #2
Re: Use and Require
Mallik wrote:
See>
> What is the difference between Use and Require.
perldoc -f use
perldoc -f require
Why do you ask?
/R
Rob Dixon Guest
-
Wolf Blaum #3
Re: Use and Require
For Quality purpouses, Mallik 's mail on Thursday 29 January 2004 18:57 may
have been monitored or recorded as:
that must be someone else> Dear Perl Gurus,
>
> What is the difference between Use and Require.
>
try perldoc -f use on your box (or [url]www.perldoc.com):[/url]
use Module VERSION LIST
use Module VERSION
use Module LIST
use Module
use VERSION
Imports some semantics into the current package
from the named module, generally by aliasing cer-
tain subroutine or variable names into your pack-
age. It is exactly equivalent to
BEGIN { require Module; import Module LIST; }
except that Module must be a bareword.
VERSION may be either a numeric argument such as
5.006, which will be compared to $], or a literal
of the form v5.6.1, which will be compared to $^V
(aka $PERL_VERSION. A fatal error is produced if
VERSION is greater than the version of the current
Perl interpreter; Perl will not attempt to parse
the rest of the file. Compare with "require",
which can do a similar check at run time.
There is tons more infomation of how use/require are simliar/different.
Enjoy. Wolf
Wolf Blaum Guest
-
Wiggins D Anconia #4
Re: Use and Require
> Mallik wrote:
Wow such a civilized answer. Some would say...>> >
> > What is the difference between Use and Require.
> See
>
> perldoc -f use
> perldoc -f require
>
> Why do you ask?
>
> /R
>
>
S R Q I R E
This is such a nice list.
Time to revisit: [url]http://www.catb.org/~esr/faqs/smart-questions.html[/url]
[url]http://danconia.org[/url]
Wiggins D Anconia Guest
-
Dan Muey #5
RE: Use and Require
> > Mallik wrote:
Who is Senior Qire?>> >> > >
> > > What is the difference between Use and Require.
> > See
> >
> > perldoc -f use
> > perldoc -f require
> >
> > Why do you ask?
> >
> > /R
> >
> >
> Wow such a civilized answer. Some would say...
>
> S R Q I R E
>
> This is such a nice list.
>
> Time to revisit: [url]http://www.catb.org/~esr/faqs/smart-questions.html[/url]Dan Muey Guest
-
Jan Eden #6
Re: Use and Require
Mallik,
I think I am just two to three weeks ahead of you in the learning curve. But what I know, I learned from O'Reilly's "Learning Perl", "Learning Perl References, Objects and Modules" and from checking "Programming Perl" from time to time. The "Perl Cookbook" is great for finding real life solutions.
If you don't like to munch through the perldoc, these books are highly recommended.
I know it's sometimes hard to find the information you need, and I commit having asked questions I could have solved (sooner or later) myself using the books or perldoc.
But definitions of perl functions can definitely be found there.
- Jan
Mallik wrote:
-->Dear Perl Gurus,
>
>What is the difference between Use and Require.
>
>Thanks,
>Malliks
>
How many Microsoft engineers does it take to screw in a lightbulb? None. They just redefine "dark" as the new standard.
Jan Eden Guest
-
Drieux #7
Re: Use and Require
On Jan 29, 2004, at 9:57 AM, Mallik wrote:
[..][..]> What is the difference between Use and Require.
The easiest way to think about it was that
once upon a time we wanted to have 'functions'
that would be in 'perl libraries' - so there
needed to be a directive that indicated that
the code 'required' certain things - such as
a minimum version of perl, or a named perl library.
the idea of the 'use Foo::Bar' on the other hand
is about indicating that the perl compiler merely
need to know that we will be using a perl Module
that is external to this file and that it will
a. look for Bar.pm in some sub_directory Foo
that is in the @INC path
b. either directly invoke the 'import()' method
of that module - or invoke it with a list of
tokens that will be imported...
So as the other person noted,
What exactly are you interested in knowing about them?
ciao
drieux
---
Drieux Guest
-
Peter Scott #8
Re: Use and Require
In article <NHBBLNCADDJDFAFMNFMMCEGPCFAA.mallikarjunk@softima .com>,
[email]mallikarjunk@softima.com[/email] (Mallik) writes:use Foo;>Dear Perl Gurus,
>
>What is the difference between Use and Require.
is equivalent to:
BEGIN {
require Foo;
Foo->import;
}
--
Peter Scott
[url]http://www.perldebugged.com/[/url]
*** NEW *** http//www.perlmedic.com/
Peter Scott Guest
-
mcdavis941@netscape.net #9
Re: Use and Require
[.. old posts snipped ..]
One important difference between 'use' and 'require' has to do with allowing your program to decide whether to include it or not.
You CAN put 'require' inside an if statement, and it will only be executed if the if condition is true, allowing your program to decide whether to execute the 'require' or not. *
if( $ThePartridgeFamilyReturnsToTV ){
* *# This will only get executed in time of dire need.
* *require Module::Of::Last::Resort;
* *import Module::Of::Last::Resort;
* *}
A 'use', on the other hand, is executed as part of the BEGIN block at the very start of your program, always, without condition. *You can put a use statement anywhere in your script, embedded as deeply within as many nested blocks as you like, and it's exactly the same as if you put it on line 1 of your script.
if( $MoonIsBlue ){
* *if( $SnowstormInHell ){
* * * *if( $DinosaursRoamTheEarth ){
* * * * * *if( $MonkeysFromButtocksAreFlying ){
* * * * * * * *use Escape::To::Alternate::Reality; # This will always get executed,
* * * * * * * * * * * * * * * * * * * * * * * * * *# no matter what,
* * * * * * * * * * * * * * * * * * * * * * * * * *# despite what the if
* * * * * * * * * * * * * * * * * * * * * * * * * *# statements lead you to think.
* * * * * * * *}
* * * * * *}
* * * *}
* *}
* *
I ran across this property while working with module CGI::Simple, which starts off by setting STDIN to binmode, whether you actually call any functions from CGI::Simple or not. *All you have to do is 'use' it, and your STDIN is in binmode. *This led to some odd behavior when testing the program from the command line.
__________________________________________________ ________________
New! Unlimited Netscape Internet Service.
Only $9.95 a month -- Sign up today at [url]http://isp.netscape.com/register[/url]
Act now to get a personalized email address!
Netscape. Just the Net You Need.
mcdavis941@netscape.net Guest
-
Robert #10
Re: Use and Require
Wiggins D Anconia wrote:
I still don't get: S R Q I R E>>>Mallik wrote:
>>>>>>>What is the difference between Use and Require.
>>See
>>
>> perldoc -f use
>> perldoc -f require
>>
>>Why do you ask?
>>
>>/R
>>
>>
>
> Wow such a civilized answer. Some would say...
>
> S R Q I R E
>
> This is such a nice list.
>
> Time to revisit: [url]http://www.catb.org/~esr/faqs/smart-questions.html[/url]
>
> [url]http://danconia.org[/url]
: )
Robert Guest
-
Wiggins D'Anconia #11
Re: Use and Require
Robert wrote:
Use, require.. each has a u and e, subtract them, and you are left with> Wiggins D Anconia wrote:
>>>>>>> Mallik wrote:
>>>
>>>> What is the difference between Use and Require.
>>>
>>>
>>> See
>>>
>>> perldoc -f use
>>> perldoc -f require
>>>
>>> Why do you ask?
>>>
>>> /R
>>>
>>>
>>
>> Wow such a civilized answer. Some would say...
>>
>> S R Q I R E
>>
>> This is such a nice list.
>> Time to revisit: [url]http://www.catb.org/~esr/faqs/smart-questions.html[/url]
>>
>> [url]http://danconia.org[/url]
>
> I still don't get: S R Q I R E
>
> : )
>
'.s.' and 'r.q.ire'... ok so it was a bad joke, it wasn't much of a
question either....
[url]http://danconia.org[/url]
Wiggins D'Anconia Guest



Reply With Quote

