Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the special variable $#_ mean in Perl?

Tags:

perl

I encountered this special variable ($#_) while browsing. Tried finding out what it means, but couldn't find any. Please let me know what this special variable mean.

like image 305
Rajath Avatar asked Dec 02 '22 01:12

Rajath


1 Answers

In Perl, you get the index of the last element of @array with the syntax $#array. So $#_ is the index of the last element in the array @_. This is not the same thing as the number of elements in the array (which you get with scalar @array), because Perl arrays are normally 0-based.

like image 66
cjm Avatar answered Dec 18 '22 09:12

cjm