in reply to Re^7: Module Announcement: Perl-Critic-1.01 (scalar)
in thread Module Announcement: Perl-Critic-1.01

My function doesn't return true/false. It returns the scalar reference of the weapon in the hand of the body object of a guy. Sometimes it's not defined, but it's not a list of weapons. if( $dude->weapon ) works. In fact, @weapons_in_left_hand = $dude->weapon also works because it returns the list of one weapon in his hand even when it's undefined (eg, if it were thrown). @weapons_in_left_hand == 1 should always be true for this function.

Suggesting that all functions have to return success or failure — just in case someone tests it in an list context — seems just a little myopic.

Although, I don't think I say it nearly as well as tye (ie: {left => $dood->query_weapon(0), right => $dood->query_weapon(1)} ), so I probably should have just left it alone.

-Paul

  • Comment on Re^8: Module Announcement: Perl-Critic-1.01 (scalar)

Replies are listed 'Best First'.
Re^9: Module Announcement: Perl-Critic-1.01 (scalar)
by chromatic (Archbishop) on Jan 27, 2007 at 06:41 UTC
    Suggesting that all functions have to return success or failure — just in case someone tests it in an list context — seems just a little myopic.

    I agree. When did I suggest otherwise? I believe I have been consistent in implying (if not outright saying, which is probably my mistake here) that it's functions that do return either success or failure that ought to watch for list context.