in reply to Shortening "$bar{foo} if exists $bar{foo}"?

I've been bothered by code duplication when using exists many a time. Unfortunately, I've never ever found a satisfactory solution (and believe me, it's not for lack of trying).

Makeshifts last the longest.

  • Comment on Re: Shortening "$bar{foo} if exists $bar{foo}"?

Replies are listed 'Best First'.
Re: Re: Shortening "$bar{foo} if exists $bar{foo}"?
by kelan (Deacon) on Oct 04, 2003 at 17:15 UTC

    How about this Perl6-ish way:

    given %foo{bar} { .() if exists }
    It's still about as much typing, though.

    kelan


    Perl6 Grammar Student