LesleyB has asked for the wisdom of the Perl Monks concerning the following question:
I know I have read, somewhere else, that it is being recommended to use one of these in declaring an object of type class
my $obj = <class>->new(); my $obj = new <class>;
in preference to the other (for some value of 'recommended', 'class' and 'prefence', probably) .
For example
use CGI; my $obj1 = new CGI; my $obj2 = CGI->new();
but I have forgotten both which and why? Can anyone here clarify this please?
I prefer the my $obj2 = CGI->new(); format and I'm hoping that's the 'better' one to use. (For some value of 'better', of course.)
Thank you for your time
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: new <class> or <class>->new()?
by davido (Cardinal) on Nov 20, 2011 at 22:30 UTC | |
by JavaFan (Canon) on Nov 21, 2011 at 11:53 UTC | |
|
Re: new <class> or <class>->new()?
by GrandFather (Saint) on Nov 20, 2011 at 22:36 UTC | |
|
Re: new <class> or <class>->new()?
by ikegami (Patriarch) on Nov 21, 2011 at 01:05 UTC | |
|
Re: new <class> or <class>->new()?
by JavaFan (Canon) on Nov 21, 2011 at 11:56 UTC |