in reply to Re: Re: Re: Re: Re: Global symbol requires explicit package name
in thread Global symbol requires explicit package name

$mailer->close is method call syntax. Perl knows that it needs to generate a subroutine call, passing an object as the first implicit parameter.

What happens if $mailer is undef or some other scalar value, which is not a blessed object reference?

Well, this generates a run time error of the form Can't call method "close" without a package or object reference

If $mailer happens to be a string containing a package name, then the method call will work, passing in the package name as first implicit parameter. For example, the new method as in:

my $pkg = "Foo::Bar"; my $obj = $pkg->new;
Note that an ordinary class method call uses this form, but with a bareword package name (which is made into a string).

Hope this helps

rinceWind