On 11-07-20 07:03 PM, Uri Guttman wrote:
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.
Not true in all cases:
#!/usr/bin/env perl
use strict;
use warnings;
package Foo;
sub foo {
print "foo\n";
}
package main;
Foo::foo();
Foo->foo();
Foo::bar();
__END__
The difference here is that `Foo:bar()` gives a run-time error; where
`Foo->bar()` gives a compile-time error.
Compile-time errors are always reported. Run-time errors are only
reported if the subroutine is called. If you have something like this,
the script would only stop for some rare condition:
if( come_rare_condition ){
Foo::bar();
}
Not something you want to discover after the code is in production. :)
--
Just my 0.00000002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Programming is as much about organization and communication
as it is about coding.
The secret to great software: Fail early & often.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/