On Tue, Feb 7, 2012 at 4:01 PM, Jeff Peng <p...@staff.dnsbed.com> wrote:
> 于 2012-2-7 15:45, lina 写道:
>
>> I am sorry, still don't get.
>>
>> $year = shift
>>
>> part
>
>
>
> Try with this code:
>
> use strict;
> my $month = "December";
> my $year = "2007" ;
>
> header($month,$year);
>
> sub header {
>        print '@_ is: ' . "@_\n";
>        my $month = shift ;
>        print '@_ is: ' . "@_\n";
>        my $year = shift ;
>        print '@_ is: ' . "@_\n";
> }
>
>
> The output:
>
> @_ is: December 2007
> @_ is: 2007
> @_ is:
>
>
> "shift" means "shift @_" in Perl.
> So the first shift, $month get the value shifted from @_, and the first
> element in @_ get removed.
> the second shift, $year get the value shifted from @_, the second element in
> @_ get removed.
> Since @_ has only two elements, so after two shift, it becomes null.
> That's all.
>
> HTH.

I thought the shift return the rest after removing the first one.

Now clear,

thanks,
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to