well, it goes to show you that when you try to inject something useful into this group, it fails. i had only 2 (TWO) respondants to my quiz. anyway i decided t owrite up the answer and some extra tutorial stuff on the theme. if you find this kind of stuff useful, let me know and maybe it could be made a (semi) regular kind of post (especially with help from other perl hackers for quiz ideas and answers). the original code was this and i asked what good is it? @array = qw( a b c d ) ; @array{ @array } = ( [ @array ] ) x @array ; there is a very useful perl idiom here which all good perl hackers should have in their vocabulary. it is called hash slices and it has many different uses which i will illustrate. it is a rare perl script (which is not trivially small) that couldn't use hash slices to improve its efficiency, clarity and elegance. the fundamental hash slice expression is: @hash{ @array } = ( list ) this is semantically equivilent to: ( $hash{ $array[0] }, ... $hash{ $array[$#array] } ) = ( list ) that means you are doing an array assignment to a list of entries in the hash. each entry is indexed by the next array value and is assigned corresponding value in the list. the list as always can be any combination of list values and arrays. the hash slice can be indexed by a list instead of an array but i haven't found it to be as useful (though it is used sometimes) so i won't go into it here. NEWBIE NOTE: remember that the @ means an array context but it is the {} after the variable name that marks it as a hash. many newbies fall for this trap. all hashes use {} and all arrays use []. the prefix char is used ONLY to mark context, not data type. Q: what are the interesting ways of assigning to a hash slice? the simplest is when you have two arrays of values and you want a hash to convert a value from one array to another @foo_array = qw( abc def ghi ) ; @bar_array = qw( jkl mno pqr ) ; @foo_to_bar{ @foo_array } = @bar_array now you can easily convert from foo values to bar values like this: $foo_value = 'def' ; $bar_value = $foo_to_bar{ $foo_value } ; $bar_value now is 'mno' you can even convert a whole array of foo values in one statement: @bar_values = @foo_to_bar{ @foo_values } ; another very common hash slice idiom i use all the time is testing if a string is in a given lsit of strings. we actually don't care about the values in the hash but i use 1 for clarity and to skip the need for exists (though exists might be faster i have never benchmarked it. i leave that as an assignment for the reader). @foo_array = qw( abc def ghi ) ; @is_a_foo{ @foo_array } = (1) x @foo_array ; $input = 'def' ; if ( $is_a_foo{ $input } ) { ... or if ( exists( $is_a_foo{ $input } ) ) { ... the assignment uses an interesting operator that most newbies never have seen. it is called the repetition operator and it is just the plain letter 'x'. it duplicates its left operand by the value of its right operand. in a scalar context it replicates its left operand as a string and returns that. in this case we have a list context and a left operand of a list, so it creates a new list with N duplicates of the list. in this case N is 3 (the scalar value of @foo_array) so we get a list of (1, 1, 1) which is assigned to the hash slice. a variant on the existance test is conversion from a string to an numerical index value. we use the range operator (..) to generate the list of integers which is assigned to the hash slice. @foo_array = qw( abc def ghi ) ; for 0 based use: @foo_to_index{ @foo_array } = ( 0 .. $#foo_array ) ; for 1 based use: @foo_to_index{ @foo_array } = ( 1 .. @foo_array ) ; $i_am_a_foo = 'def' ; $foo_index = $foo_to_index{ $i_am_a_foo } ; note that this form can also be used to test if a value is a foo as well as converting it to an index. remember though that if you use the 0 (zero) based version, you MUST use exists since the value 0 will be false for the simple test. NEWBIE NOTE: notice the selection of names for each of the hashes, %foo_to_bar, %is_a_foo, $foo_to_index. they are very descriptive of the operation they perform. in fact i treat them as very fast and simple subroutines. indexing into a hash is a transformation of the input data to the output values. thinking this way will make your perl scripts much easier to design and write. now let us look at the original quiz version of the hash slice idiom. @array{ @array } = ( [ @array ] ) x @array ; the first thing to notice is that the hash AND the array are both named array but they are DIFFERENT variables. hashes and arrays (and scalars) have different nam spaces. i chose the same name to make the quiz a little trickier. other than that, the left side is just an assignment to a hash slice, but what is being assigned? notice that there is the 'x' operator and @array on its right as its replication count and some list on its left and we are in a list context (hash slices are list contexts). so we are creating a replicated list of an anonymous array which contains the values in @array. this means the hash %array looks like this: %array = ( 'a' => [ 'a', 'b', 'c', 'd' ], 'b' => [ 'a', 'b', 'c', 'd' ], 'c' => [ 'a', 'b', 'c', 'd' ], 'd' => [ 'a', 'b', 'c', 'd' ], ) ; except that all the anonymous arrays are the same one (the above code creates 4 different anonymous arrays with the same values). what good is this structure? well i was thinking about alias expansion when i devised this. what if you had a set of aliases and you wanted to expand any one of them to the full list. this data structure will do that. enter any of the single elements and you get the entire list. by itself it isn't much but what if you had multiple sets of aliases? you could do this: @foo_list = qw( a b c d ) ; @bar_list = qw( j k l m n o ) ; @baz_list = qw( w x ) ; @expand_aliases{ @foo_list } = ( [ @foo_list ] ) x @foo_list ; @expand_aliases{ @bar_list } = ( [ @bar_list ] ) x @bar_list ; @expand_aliases{ @baz_list } = ( [ @baz_list ] ) x @baz_list ; now if you had a single token of unknown type you could get its alias list in one step: @aliases = @{ $expand_aliases{ $alias } } ; NEWBIE NOTE: the surrounding @{} is used to dereference the stored anonymous list back into a list for assignment to @aliases. this is only one way of using this idiom. try to think of others as an exercise and report them back to me. lesson is over (for now). uri