Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Perl Syntax - What's the difference?

by Corion (Pope)
on Apr 09, 2018 at 12:08 UTC ( #1212576=note: print w/replies, xml ) Need Help??


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 (Cardinal) 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1212576]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2020-10-22 07:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (225 votes). Check out past polls.

    Notices?