>>>>> "M" == Marc  <sono...@fannullone.us> writes:

  M>    I've noticed that the following two lines seem to be equivalent when 
calling a sub from a module called Lib.pm:
  Lib-> load_config("config.dat");

  M> Lib::load_config("config.dat");

  M>    Is this just a case of TIMTOWTDI or is there a difference in how
  M>    they do what they do?

they are actually very different. the :: call is just a plain sub call
with a fully qualified path. if the sub was imported into the current
package you wouldn't even need the Lib:: part.

the other is a class method call. it has two major differences. first it
will pass its class (or object, the arg before ->) as the first arg in
the call. the second thing is that it will search the class hierarchy
(using the package global's @ISA) to find that method if it isn't in the
Lib class.

so don't think they are even similar as one is a sub call and the other
is a class method call. they aren't interchangeble at all

uri

-- 
Uri Guttman  --  uri AT perlhunter DOT com  ---  http://www.perlhunter.com --
------------  Perl Developer Recruiting and Placement Services  -------------
-----  Perl Code Review, Architecture, Development, Training, Support -------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to