Thank you very much.
 
Lizhe
 
________________________________

From: Stephen Kratzer [mailto:[EMAIL PROTECTED]
Sent: Tue 6/5/2007 10:09 AM
To: beginners@perl.org
Cc: Xu, Lizhe
Subject: Re: Command Splice()



On Tuesday 05 June 2007 09:38:51 Xu, Lizhe wrote:
> Hi All,
> =20
> The example given for splice function in the perldoc shows
> sub aeq {
>  ...
>  my(@a)=3D splice (@_, 0, shift);
>  ...
> }
> I am confused about what the splice command does with the shift command =
> and what the result of the command. Thanks.
>
>
>
>
> Lizhe

Look at how aeq is called. The lengths of the arrays are passed before the
arrays. If the lengths are correct, the lengths are what the calls to shift
should return. Using these lengths and an offset of 0 should ensure that
splice removes all elements of the arrays following the length arguments.
So, "my(@a) = splice(@_,0,shift);" assigns to @a the values from the first
array in the call to aeq and "my(@b) = splice(@_,0,shift);" assigns to @b the
values from the second array in the call to aeq. Then, the lengths of the two
arrays are compared, and finally, all their elements are compared.



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


Reply via email to