in reply to Re: YAOOM
in thread YAOOM

Just to be picky: you either want a grep instead of a map or you need to rewrite the foreach since can() returns a coderef:

foreach my $meth ( grep { $person->can( $_ ) } ...

Chris
M-x auto-bs-mode

Replies are listed 'Best First'.
Re: Re: Re: YAOOM
by dragonchild (Archbishop) on Dec 08, 2001 at 00:22 UTC
    The code, as written, works just fine. can() will either return a coderef or undef. Hence, the if $meth check. I used map to allow for warnings, if desired. If no warnings are desired, grep is the better way to go.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      Excuse me, just being a dingdong. Nothing to see here. Must test code before opening yap :-)

      Chris
      M-x auto-bs-mode