Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: loading modules using 'use'

by angshuman (Novice)
on Jul 12, 2010 at 11:57 UTC ( [id://848993]=note: print w/replies, xml ) Need Help??


in reply to Re: loading modules using 'use'
in thread loading modules using 'use'

Hi Monk,

Thank you so very much for the step-by-step explanation,

OK, in 2.1.1.1 you say A is loaded and compiled. So, what essentially is the difference between
A.pm ~~~~~~~~~~ package A; require Exporter; @ISA = (Exporter); @EXPORT = qw(abc); AND A.pm ~~~~~~~~~~ package A; BEGIN{ require Exporter; @ISA = (Exporter); @EXPORT = qw(abc); }
as irrespective of wheather BEGIN is there A is loaded and compiled, when 'use A' is encountered. But the BEGIN blocks provides a significant improvement in case of circular dependency/inheritance issues. How does the BEGIN block create such a difference then.

Replies are listed 'Best First'.
Re^3: loading modules using 'use'
by ikegami (Patriarch) on Jul 12, 2010 at 22:20 UTC

    If that's the entire file, there's essentially no difference between those two snippets.

    The BEGIN will affect the order in which those statements will be executed in relation to other statements in the file.

      That was just a sample module... Lets assume its got plenty of subroutines written in it, which are also included in the @EXPORT list. Then ???
        With BEGIN, @EXPORT will be initialised before the subs are compiled. Without, after.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://848993]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-23 05:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found