in reply to Store only object data but not the whole class

FYI - when run, your posted code displays:

Can't locate object method "Whatever" via package "new" (perhaps you forgot to load "new"?) at -e line 9.

The object creation should be (my preferred syntax):

my $obj = Whatever::->new();

        "Software interprets lawyers as damage, and routes around them" - Larry Wall

Replies are listed 'Best First'.
Re^2: Store only object data but not the whole class
by AnomalousMonk (Archbishop) on Aug 30, 2016 at 18:37 UTC
    ... object creation ... (my preferred syntax):

    my $obj =  Whatever::->new();

    Just as a matter of curiosity, why do you prefer the trailing  :: in the constructor call?


    Give a man a fish:  <%-{-{-{-<

      "Just as a matter of curiosity, why do you prefer the trailing :: in the constructor call?"

      There's a discussion about this in "perlobj: Invoking Class Methods".

      — Ken

      The "::" makes it clear that the "Whatever" is a package name. Other possible barewords could be "sub", or "File handle".

              "Software interprets lawyers as damage, and routes around them" - Larry Wall

Re^2: Store only object data but not the whole class
by exilepanda (Friar) on Aug 30, 2016 at 15:13 UTC
    Ouch.. sorry for my finger slipped, that  -> was obviously unwanted. that should be new Whatever(); ( for my very old school fashion ). Thanks for point out!