> -----Original Message-----
> From: Todd Wade [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 17, 2002 6:40 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Is it a difference?
>
>
>
> "Bob Showalter" <[EMAIL PROTECTED]> wrote in message
> 2E4528861499D41199D200A0C9B15BC031BAD4@FRISTX">news:2E4528861499D41199D200A0C9B15BC031BAD4@FRISTX...
> > >
> > > my $q = new CGI;
> > > my $q = CGI -> new();
> > >
> > > Can I use any of these 2 lines with no problem.
> > > I haven't seen explanations for the differences between
> these lines.
> >
> > These are equivalent. See the discussion under "Method Invocation"
> > in perldoc perlobj.
>
> Not quite. The former is called "indirect object notation", a
> subject that
> owns almost the entire page 446 in the cookbook. Near the the
> beginning of
> the discussion it starts: "It has two grave problems...." and
> finishes with:
> "... The infix arrow notation using -> dosent suffer from
> either of these
> disturbing ambiguities, so we recommend you use it exclusively."
>
> True, for this example it produces the same result, but IMHO,
> its usually in
> our best interest to follow the recommendations of Mr.
> Christiansen and Mr.
> Torkington
Yes, you are correct. As a matter of fact, I was just recently
"burned" by one of these ambiguities when I tried to do something
along the lines of the following inside a method:
package Bar;
sub new
{
my $class = shift;
bless {}, $class;
}
sub run
{
my $package = 'Foo';
my $obj = new $package; # Create a new Foo? Nope!
$obj->baz();
}
That didn't do what I wanted until I changed it to:
my $obj = $package->new(); # Create a new Foo. Yes!
(the package name is actually derived at run-time; thus the need
to store it in a variable. My module is something similar to
Apache::Registry)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]