On Mar 4, 2015, at 8:15 PM, Brandon McCaig wrote:
>
> That could matter in rare, silly cases. In most cases, it
> wouldn't really matter (usually we "require" modules and assert
> versions at the beginning of a program or module before anything
> else is actually done).
That explains it.
On 5 March 2015 at 17:15, Brandon McCaig wrote:
> Uri means that use is
> effectively requiring the module with a BEGIN block. That means
> that it will execute before any other code that isn't in a BEGIN
> block.
>
It may also be worth mentioning that "BEGIN" is actually a sub. A special
sub t
On 03/04/2015 11:15 PM, Brandon McCaig wrote:
I think that generally you should be using `use' unless you have a
specific need to use require directly. `use' will call require() under
the surface when needed so to you it's basically the same, but it has
added benefits that make sense generally.
On Wed, Mar 04, 2015 at 06:26:41PM -0800, SSC_perl wrote:
> So there's only really a difference for loading modules, not
> for setting the minimum version number?
There could be a difference if code with side effects is done
first. By being done at compile-time, Uri means that use is
effectively r
On Mar 4, 2015, at 6:14 PM, Uri Guttman wrote:
>
> it is more about when the check is done. use is done at compile time and
> require is done at run time. also use effectively calls require to load the
> module and then it may do importing as well. when a module is loaded it will
> run any use
On 03/04/2015 09:12 PM, SSC_perl wrote:
Hi all,
I'm just curious about something. What's the difference between using
require 5.016;
or
use 5.016;
The only thing I've seen is that if 5.16 isn't installed, 'use' outputs:
Perl v5.16 required--this is only v5.10.1, stopped at
Hi all,
I'm just curious about something. What's the difference between using
require 5.016;
or
use 5.016;
The only thing I've seen is that if 5.16 isn't installed, 'use' outputs:
Perl v5.16 required--this is only v5.10.1, stopped at shop.cgi line 26.
BEGIN failed--compilatio
Chas. Owens wrote:
> [trim]
$string =~ s/^[ ]*(.*)[ ]*$/$1/;
That changes the string when not necessary.
I prefer this:
s/\s+$//, s/^\s+// for $string; # rtrim + ltrim
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@pe
2009/1/23 ben perl :
> Hi Chas,
>
> Can you give me an example when one would be used over the other? So, is
> require used more for efficiency, so we load the module only if we need it?
> Thanks,
> -Ben
>
Many time we need 'require' not 'use'.
For example, given this .pm:
package mylib;
requir
On Thu, Jan 22, 2009 at 19:12, Rob Dixon wrote:
> Chas. Owens wrote:
>>
>> What is so hard about
>>
>> $string =~ s/^[ ]*(.*)[ ]*$/$1/;
>
> It's not hard, it just won't strip trailing spaces because your captured
> string
> has a greedy quantifier!
>
> I usually use
>
> s/^\s+//, s/\s+$// for $s
Chas. Owens wrote:
>
> What is so hard about
>
> $string =~ s/^[ ]*(.*)[ ]*$/$1/;
It's not hard, it just won't strip trailing spaces because your captured string
has a greedy quantifier!
I usually use
s/^\s+//, s/\s+$// for $string;
Rob
--
To unsubscribe, e-mail: beginners-unsubscr...@perl
On Thu, Jan 22, 2009 at 18:35, Owen wrote:
>> Hi Chas,
>>
>> Can you give me an example when one would be used over the other? So,
>> is
>> require used more for efficiency, so we load the module only if we
>> need it?
>> Thanks,
>> -Ben
>
>
> Bit of a conundrum there, if you don't need a module,
On Thu, Jan 22, 2009 at 18:01, ben perl wrote:
> Hi Chas,
> Can you give me an example when one would be used over the other? So, is
> require used more for efficiency, so we load the module only if we need it?
> Thanks,
snip
Efficiency is one reason (loading modules you won't use is wasteful),
b
> Hi Chas,
>
> Can you give me an example when one would be used over the other? So,
> is
> require used more for efficiency, so we load the module only if we
> need it?
> Thanks,
> -Ben
Bit of a conundrum there, if you don't need a module, why include it
in your program.
Anyway you might have y
Everyone,
> > I am could never understand the difference between use vs require? If
> > "require" is older way of including modules, why not just make it
> obsolete.
> snip
>
> Well, first off, because use uses require. The use looks something
> like this internall
On Thu, Jan 22, 2009 at 17:33, ben perl wrote:
> Hi Everyone,
> I am could never understand the difference between use vs require? If
> "require" is older way of including modules, why not just make it obsolete.
snip
Well, first off, because use uses require. The use looks
Hi ben,
ben perl wrote:
Hi Everyone,
I am could never understand the difference between use vs require? If
"require" is older way of including modules, why not just make it obsolete.
nope there's even more than that.
"use" loads the source when starting the script
Hi Everyone,
I am could never understand the difference between use vs require? If
"require" is older way of including modules, why not just make it obsolete.
Thanks,
-Bandeep
heh, that was it, thanks a bunch.
Randal L. Schwartz wrote:
>> "Christopher" == Christopher J Bottaro
>> <[EMAIL PROTECTED]> writes:
>
> Christopher> My::Utils
> Christopher> use Exporter;
>
> Do you have "@ISA = Exporter" too? Much easier to write this as
>
> use base 'Export
> "Christopher" == Christopher J Bottaro <[EMAIL PROTECTED]> writes:
Christopher> My::Utils
Christopher> use Exporter;
Do you have "@ISA = Exporter" too? Much easier to write this as
use base 'Exporter';
This might be why it needs to be require'd instead of use'd.
--
Randal L. Sc
i have 4 packages:
PackageA
use IO::File;
require My::Utils::Reader
PackageB
use IO::File;
use XML::Writer;
My::Utils::Reader
use My::Utils;
My::Utils
use Exporter;
in my perl program, i dynamically load PackageA and PackageB like this:
eval("require $package_name1");
eval("require $package_n
> -Original Message-
> From: Jeff [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 11, 2002 1:24 PM
> To: [EMAIL PROTECTED]
> Subject: Use vs Require
>
>
> I'm new to perl, but have a background in C.
>
> Can someone tell me what is the difference be
At 01:27 PM 7/11/02 -0400, Shishir K. Singh wrote:
> >I'm new to perl, but have a background in C.
>
> >Can someone tell me what is the difference between 'use' and
> 'require'? When do you
> >use one and not the other? Seems they both are comparable to a C
> header file (.h).
>
> >Thanks in a
>I'm new to perl, but have a background in C.
>Can someone tell me what is the difference between 'use' and 'require'? When do you
>use one and not the other? Seems they both are comparable to a C header file (.h).
>Thanks in advance.
use is resolved during compile time whereas require is
I'm new to perl, but have a background in C.
Can someone tell me what is the difference between 'use' and 'require'? When do you
use one and not the other? Seems they both are comparable to a C header file (.h).
Thanks in advance.
Jeff
__
25 matches
Mail list logo