in reply to Re: Unusual "Can't locate object method"
in thread Unusual "Can't locate object method"

Thanks for the reply's.

I mention that the title() sub works as expected in other contexts. I should have made that more plain.

  • Comment on Re^2: Unusual "Can't locate object method"

Replies are listed 'Best First'.
Re^3: Unusual "Can't locate object method"
by dsheroh (Monsignor) on Nov 01, 2024 at 09:38 UTC
    Yes, and the title() method also works as expected in this context, which is why your output includes "title:Title Test".

    Your error is coming from the following line, where it calls track()->toCString() because, as others have stated, track() returns a plain integer, not an object, and plain integers don't have object methods. Because they're not objects.

    Change that line to say 'track', $file->tag()->track(); and it will do what you presumably want it to. (Namely, it will print "track0".)

      There are none so blind as those who will not ... read the code carefully.

      Thanks for helping me to see the obvious.

Re^3: Unusual "Can't locate object method"
by ysth (Canon) on Nov 01, 2024 at 04:50 UTC
    Right, the title call succeeds and the title is output. Then the track toCString call fails because track() returns an integer, not an object that you can call a method on.
    --
    A math joke: r = | |csc(θ)|+|sec(θ)| |-| |csc(θ)|-|sec(θ)| |