Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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

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

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

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:


stops working but


continues to work, or maybe:

$myobject->ymd $foo;

stops working but


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.

Replies are listed 'Best First'.
Re^5: Perl Syntax - What's the difference?
by LanX (Cardinal) on Apr 09, 2018 at 13:09 UTC

    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


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

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2020-10-22 06:38 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (225 votes). Check out past polls.