develooper Front page | perl.perl6.language | Postings from April 2002

Ex4 smart match question

Thread Next
From:
jadams01
Date:
April 5, 2002 14:26
Subject:
Ex4 smart match question
Message ID:
Springmail.0994.1018045532.0.91122000@webmail.atl.earthlink.net
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?

John A

They laughed at Joan of Arc, but she went right ahead and built it.
   ---Gracie Allen

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About