Thanks for the detailed explaination. So to summarize I get a hash that I'll
call parseHash that:

        $parseHash{'command'} = 'COMMAND ARG1-VALUE, ARG2-VALUE, ARG3-VALUE';
or
        $parseHash{'comment'} = 'here is a comment';

I can print the contents of the hash with:

        print "$parseHash{'command'}\n";
or
        print "$parseHash{'comment'}\n";

This leads to my next question. Since the returned hash does not have a
name, how do I access it? Who is it returned to?

jr





> -----Original Message-----
> From: Orton, Yves [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 26, 2002 2:08 AM
> To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
> Subject: RE: Line contination characters - how do I access
> thesevariables
>
>
> [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
>
>
>


Reply via email to