[EMAIL PROTECTED] asked > Damian gave the solution I am studying. I have attached it at > the bottom. I don't understand the section between the {{ }}. For example: > { {command => $item[-1]} }
Ok. this is at first glance a bit confusing I agree. The {} brakets are heavilly used in Perl and have multiple meanings. The explanation is much easier to grok when you see it in context > singleline_command: > '//' /.*/ > { {command => $item[-1]} } ^ ^ ^ ^ ^ ^ | | | | | | 1 2 3 4 2 1 1. The outter {} are a block definition. 2. The inner {} are an anonymous hash creation. 3. This is a "fat comma". => This is syntactically equivelent to a normal comma, except that Perl treats the object to its left as quoted if necessary. 4. This access the last element in the @item array. @item contains a list of the parts that were matched. Negative numbers when used as indexes to an array refer to the index of the array starting from its end. Thus $item[-1]==$item[$#item]==$item[@item-1] So the end result is that this little piece of highly idomatic perl returns an anonymous hash containing one key 'command' whose value is that of whatever was matched by /.*/ HTH Yves