in reply to Sort and related stuff

The code posted above includes the following lines:
my @First=split /\./,$a||shift; my @Second=split /\./,$b||shift; foreach(0..(($#First>$#Second)?$#Second:$#First))

Could anyone explain to me what the # in the variable name does?

The Llama and Camel books describe how # can be used for comments, formats and the shebang execute command. But in this code # affixed to the name of an array appears to be neither a comment or a format or a shebang. # affixed to the start of an array name automagically become — well, I don't know what it becomes.

Does anybody know?

Replies are listed 'Best First'.
(ichimunki) re: What does # do in a variable name?
by ichimunki (Priest) on Feb 23, 2001 at 17:47 UTC
    $#list_name returns the index number of the last element in @list_name. This will give you an off-by-one error if you try to use it to count the number of elements in an list (so use $count = @list_name for that). Also useful for erasing a list: $#list_name = -1;

    See perldoc perldata for more information.