I must admit that whenever I've been coaching people on creating new objects, I almost always tell them to declare an object like this:
my $objectBlah = Blah::Object->new();
I guess my reasoning behind this is that you should always be clear on creating a new instance of an object. I can't think of too many instances where I'd do
my $foo = $bar->new();
...that just wouldn't, generally, cut the mustard with me -- unless you *really* needed another instance of the same object to do other stuff with. As I write this, I was trying to think of when I've needed to do this exact thing, and I honestly can't think of any instances that I've done that.

However -- that may merely be an indictment of how I like to design my objects and code, generally.....!

Also, I, personally dislike the following syntax:
my $foo = new Bob::Object;
I can't think of an exact reason -- probably just that I think that perl's syntax is nearly always based around using something like (in the case of reading a constant item that you've set up in your object framework) :-
my $constantStuff = Bob::Constants::CONSTANT_STUFF;
Adding in something like this:
my $bob = new Bob::Object;
...just doesn't fit (in my head at least) with the nice perl way of doing things.

I know my reason doesn't make too much sense: I just like a bit of consistency........!

PS I'm actually really enjoying this conversation about something as simple as the best new() function to use. It reminds me of why I love perl so much.......!

In reply to Re^2: new() function: incorrect? by lukeyboy1
in thread new() function: incorrect? by lukeyboy1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.