On Sun, May 30, 2004 at 04:57:36PM -0700, Rob Richardson wrote:

> Greetings!
> 
> I found the source of the "impossible error".  Here are the lines that
> caused it:
> 
>       my $userList = new UserList($userFile);
>       my $user = UserList->GetUser($logname);
> 
> I have a "use UserList" line near the top of this file.  I also have
> "use strict" and "use warnings".  
> 
> I would have expected Perl to complain about the bareword "UserList" in
> the second line, or find some other way to complain about it.  Instead,
> it merrily tried to execute this line, and threw the error message
> halfway through the GetUser() function in the UserList package.  Why
> didn't an error get thrown?  If this is a valid construct in Perl, how
> is it supposed to be used?

Those two lines are probably more similar that you expect.

C<my $userList = new UserList($userFile);> is known as indirect object
syntax, and it is almost the same as C<my $userList =
UserList->new($userFile);>.

Knowing this, you may perhaps see why your GetUser method was being
called with a first parameter of "UserList".

Indirect object syntax is slightly frowned upon these days since there
are some rare situations in which it may not do what you expect.  See
http://ftp.ics.uci.edu/pub/websoft/libwww-perl/archive/1998h1/0109.html

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to