On Fri, 5 Apr 2002 [EMAIL PROTECTED] wrote:
> Does one of these items not belong?
>
> >From Exegesis 4:
>
> This new turbo-charged 'smart match' operator will also work on arrays, hashes and
>lists:
>
>
> if @array =~ $elem {...} # true if @array contains $elem
>
> if $key =~ %hash {...} # true if %hash{$key}
>
> if $value =~ (1..10) {...} # true if $value is in the list
>
> if $value =~ ('a',/\s/,7) {...} # true if $value is eq to 'a'
> # or if $value contains whitespace
> # or if $value is == to 7
>
> It's very cool--but why is it $key =~ %hash but $value =~ @array rather than one way
>or the other?
Probably because you never really want to find out whether some value is
in a hash, you just want to know whether a key has a value to look up. If
you need to know whether a value is in a hash, it'd be good to rethink
your design.
That and it's stupid to see if an index is in an array. You can just say
$ind < @array. So, it DWIMs. In my opinion, it does so very well.