> > As what I've learnt, 'use' is working during the compile time, 
> > where 'require' works at runtime, however, I have problem on 
> > understand this..
> > 
> > ### code ###
> > sub A
> > {    my ($case) = shift;
> >         if ($case == 0) { require "lib0.pl" ; use somePm; use 
> > anotherPm ; &doSth(...) }
> >         if ($case == 1) { require "lib1.pl" ; use somePm; use 
> > anotherPm ; &doSthEls(...) }
> >         if ($case == 2) { require "lib2.pl" ; use somePm; use 
> > anotherPm ; &doSthAnotherEls(...)}
> > }
> > 
> > sub B
> > {    my ($case) = shift;
> >       #  something similar to A
> > }
> > 
> > sub C
> > {    my ($case) = shift;
> >       #  something similar to A
> > }
> > 
> > ### EOF Code ###
> > 
> > Say, if above is called by require, then I think it probrably 
> > those inline reqire and use are calling when the sub is called 
> > and when the case is matched... however, what about the 
> > above finally becomes a .pm would those use, require will be 
> > loaded once I use the above pm ? 
> > 
> > I do really concern about the loading of system... so which 
> > is a better method for lower the loading ?  I think exporter can 
> > help to lower some loading, but how about those.... Sorry,  I 
> > don't know how to phrase the question... =), unless I have some 
> > more clear concept on what is the real practise of runtime and 
> > compile time... 
> 
> First of all, read:
> 
>    perldoc -q require
> 
> For a detailed explanation of the differences.

First of all, please forgiving I am really poor in English, I've read
require, use and do for many many times, but I just can't understand
at all... What I can study from perldoc is only about the syntax, 
or method, most of docs there I can't understand. = (

> Second, the run-time use of require would "generally" be used when
> there are multiple modules that can do the job, or there is some
> "optional" feature in your program that can be activiated if a
> given module is present. Consider the CPAN module. It will download
> tarballs using LWP if you have that installed. If not, it will try
> Net::FTP. (And if you don't have that it will try other things...)

Do you mean I rather use those existed modules, instead of writing my
own stuff ? and do something like use LWP::Lite instead of use LWP ?

> Of course, you should also avoid creating huge "do-everything" modules
> and break your modules up into logical groupings that allow you to
> avoid having to compile chunks of stuff you won't be using...

Do you mean I better do something like use strict  qw(subs),  instead of
use strict ? So can narrow down the loading, and targeting to only stuff
that I really need ?



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to