in reply to object ref syntax

If i do my $b=$bar."_edit" and $o->$b() it works, but I don't wanna make temp vars like that.
But that's about the only way to do an indirect method call. You can horse around with UNIVERSAL::can to get at it a bit differently, but you're still gonna end up with either a temporary variable or a value in passing.

Symbolic method calls are rare enough that it was deemed reasonable to restrict them to simple scalars.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: object ref syntax
by jhanna (Scribe) on Feb 08, 2002 at 23:55 UTC
    *sigh* -- I'm spoiled by perl's TAAWTDI (there's always another way to do it) heritage.

      Just to elucidate on merlyn's can method (no pun intended), the following works just fine:

      $b = "foo"; $o->can($b . "_edit")->();

      bbfu
      Seasons don't fear The Reaper.
      Nor do the wind, the sun, and the rain.
      We can be like they are.

        If you call a method like a function, and in this case you do, you want to pass the object as the first argument. $o->can($b . "_edit")->($o); -Anomo