Re: Use vs Require with version number

2015-03-05 Thread SSC_perl
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.

Re: Use vs Require with version number

2015-03-05 Thread Kent Fredric
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

Re: Use vs Require with version number

2015-03-04 Thread Uri Guttman
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.

Re: Use vs Require with version number

2015-03-04 Thread Brandon McCaig
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

Re: Use vs Require with version number

2015-03-04 Thread SSC_perl
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

Re: Use vs Require with version number

2015-03-04 Thread Uri Guttman
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

Use vs Require with version number

2015-03-04 Thread SSC_perl
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

trim (was: Re: use vs require)

2009-01-24 Thread Dr.Ruud
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

Re: use vs require

2009-01-22 Thread Ralf Peng
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

Re: use vs require

2009-01-22 Thread Chas. Owens
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

Re: use vs require

2009-01-22 Thread Rob Dixon
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

Re: use vs require

2009-01-22 Thread Chas. Owens
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,

Re: use vs require

2009-01-22 Thread Chas. Owens
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

Re: use vs require

2009-01-22 Thread Owen
> 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

Re: use vs require

2009-01-22 Thread ben perl
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

Re: use vs require

2009-01-22 Thread Chas. Owens
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

Re: use vs require

2009-01-22 Thread Sebastian Cabrera
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

use vs require

2009-01-22 Thread ben perl
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

Re: use vs. require in modules

2004-08-04 Thread Christopher J. Bottaro
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

Re: use vs. require in modules

2004-08-04 Thread Randal L. Schwartz
> "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

use vs. require in modules

2004-08-04 Thread Christopher J. Bottaro
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

RE: Use vs Require

2002-07-11 Thread Bob Showalter
> -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

RE: Use vs Require

2002-07-11 Thread Peter Scott
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

RE: Use vs Require

2002-07-11 Thread Shishir K. Singh
>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

Use vs Require

2002-07-11 Thread Jeff
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 __