http://qs321.pair.com?node_id=1212576


in reply to Re: Perl Syntax - What's the difference?
in thread Perl Syntax - What's the difference?

There is no code (as posted) where ymd $foo is shown.

The error message occurs for any string that gets used as a class/object without being blessed.

Replies are listed 'Best First'.
Re^3: Perl Syntax - What's the difference?
by LanX (Saint) on Apr 09, 2018 at 12:47 UTC
    The OP said the only thing he changed where "underscore introduced in column names" , so consequently I expected some side effects in code he is executing behind the scene.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Wikisyntax for the Monastery

      At least given the above context of calling ->ymd as a method, I wonder what code would have worked before but now not work due to not having parentheses. To me this interpretation looks as if there is a case where:

      $myobject->ymd;

      stops working but

      $myobject->ymd();

      continues to work, or maybe:

      $myobject->ymd $foo;

      stops working but

      $myobject->ymd($foo);

      continues to work.

      At least in my trials, I can't get the version without parentheses to even compile:

      > perl -wle "$myobject = bless {}; $myobject->ymd $foo" Scalar found where operator expected at -e line 1, near "->ymd $foo"

      Of course, it could be use of indirect object syntax such that the method ymd was changed to parse differently, but that's also something that would be hard to elicit the stated error message from.

      I think most (if not all) cases when you get

      Can't locate object method "ymd" via package "123456"

      ... the cause is that you tried to treat an unblessed value like an object and the value was not a class name.

        Well

        1. The OP gave insufficient informations, that's why I guessed.

        2. It's obvious that I guessed because I said "probably"

        3. It's obvious that I was referring to indirect object syntax, since I gave an example.

        4. It's obvious that I didn't mean the code shown since I said "somewhere"*

        So in the end you were right and my theory was wrong.

        But what's the consequence of your reaction now?

        Shall I stop speculating when the OPs are not giving the full picture?

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Wikisyntax for the Monastery

        update

        * well I din't said somewhere , but it's obvious that i didn't mean the code shown.