in reply to new <class> or <class>->new()?

my $obj = CGI->new(); is preferable.

The other method is known as "Indirect Object Syntax", and is usually discouraged because the syntax is ambiguous, and in some cases can be interpreted the wrong way. There's an explanation in perlobj under the heading, "Indirect Object Syntax".


Dave

Replies are listed 'Best First'.
Re^2: new <class> or <class>->new()?
by JavaFan (Canon) on Nov 21, 2011 at 11:53 UTC
    CGI->new
    is ambiguous as well. Are you calling CGI::new() here, or CGI()->new()? If you want to be clear, write:
    CGI::->new
    which is not ambiguous.