http://qs1969.pair.com?node_id=262276


in reply to Re: Re: CPAN Module Proposal: Business::Ship
in thread CPAN Module Proposal: Business::Ship

I'm following up from sauoq's note on the indirect object syntax because zie didn't provide the fixed syntax (and that's all this is - syntax).

$obj = Class->new;

versus

$obj = new Class;

You can get yourself into hot water by using the second form as its ambiguous - the first is unambiguous and works all the time.

Replies are listed 'Best First'.
Re(4): CPAN Module Proposal: Business::Ship
by Dog and Pony (Priest) on Jun 02, 2003 at 09:52 UTC
    the first is unambiguous and works all the time.

    Just to be the mega-pain, I do seem to recall that it isn't 100% unambiguous - it could mean $obj = Class()->new().

    The way to be certain I think was to use either new Class:: or Class::->new (ugly, ain't it?).

    Nope, I don't ever see it written like that either, and maybe that is how it used to be - I didn't whip up a test script since I'm too lazy. Just felt like being a bit obstinate before my coffee. ;-)


    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.