in reply to Getting times (weeks, days, hours, minutes, seconds)

There is an easy way to understand -> (at least I hope so):

$something->func($x);

is nearly the same as

func($something,$x);

with func a subroutine out of the package (called class) that $something belongs to

There is also an easy way to understand printf:

printf("bla %xyz chink %ru wong",$a,$b);

is somewhat equivalent to

print "bla $a chink $b wong";

The printf often does some conversions of the variables, but basically thats it.

Now in the code someone on IRC gave you the printf is not the normal builtin perl printf, since it was called with the -> syntax. Instead it must be subroutine out of the package $t belongs to. What package does $t belong to? Date::Manip::Delta, since $t was created with my $t = Date::Manip::Delta->new;

UPDATE: Added the word 'nearly'

Replies are listed 'Best First'.
Re^2: Getting times (weeks, days, hours, minutes, seconds)
by DrHyde (Prior) on Jul 05, 2010 at 10:16 UTC
    $something->func($x) and func($something,$x) aren't exactly equivalent. The second one will ignore inheritance.
Re^2: Getting times (weeks, days, hours, minutes, seconds)
by ikegami (Patriarch) on Jul 05, 2010 at 16:29 UTC
    $something->func($x)
    is rarely equivalent to
    func($something, $x)
    More like
    Class::Or::Superclass::Of::Something::func($something, $x)

    Your explanation just reinforces the OP's misconception that printf gets called, but it's not involved one bit.

      Not if she reads the complete sentence, and definitely not if she reads the complete post. And if you throw "Class::Or::Superclass::Of::Something::func($something, $x)" at someone unfamiliar with basic concepts of perl OO, you might as well offer a zen koan ;-).

        I didn't say it was wrong, just misleading. "printf means exactly what you think it means except it really means something completely different." and "There is also an easy way to understand printf" when the "real" printf isn't used in the snippet.

        And if you throw "Class::Or::Superclass::Of::Something::func($something, $x)" at someone unfamiliar with basic concepts of perl OO, you might as well offer a zen koan ;-).

        That's part of what I'm saying.