Spark Shen wrote:
> 2007/2/12, John W. Krahn <[EMAIL PROTECTED]>:
>>
>> Spark Shen wrote:
>>
>> > I am a fresh bird on perl. :-) Could gurus help me to understand this
>> > statement.
>> >
>> > *HTTP::Request->new(GET => $url);*
>> >
>> > How does perl parse the struct *GET => $url* here.
>>
>> (GET => $url) is a list of two elements.  It could also be written as
>> ('GET',
>> $url)  (The => operator is just a comma that also stringifies its
>> left-hand
>> operand.)
> 
> So, it's just like the usage in hash array?

You mean like:

my %hash = ( one => 'two', three => 'four' );


That could also be written as:

my %hash = ( one => two => three => four => );

Or:

my %hash = ( 'one', 'two', 'three', 'four' );

Or:

my %hash = qw( one two three four );


> And IIRC function calls expect
> list context, so => is in list context?

Subroutine arguments are *usually* (by default) in list context.  You can
change the context by using prototypes but it is not recommended.  Using => or
, does not define context it is just used to separate the items in the list.



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to