What does this mean in Perl 1..$#something?
perl
Solution
The `$#` is the syntax for getting the highest index of the array in question, so `$#thing` is the highest index of the array `@thing`. This is documented in perldoc perldata
`..` is the range operator, and `1 .. $#thing` means a list of numbers, from 1 to whatever the highest index of `@thing` is.
Using this list inside array brackets with the `@` sigill denotes that this is an array slice, which is to say, a selected number of elements in the `@place` array.
So assuming the following:
my @thing = qw(foo bar baz);
my @place = qw(home work restaurant gym);
then `@place[1 .. $#thing]` (or `1 .. 2`) would expand into the list `work, restaurant`.
It is correct that `#` is used for comments, but not in this case.
Problem
I have a loop for example : ``` for my $something ( @place[1..$#thing] ) { } ``` I don't get this statement `1..$#thing` I know that # is for comments but my IDE doesn't color #thing as comment. Or is it really just a comment for someone to know that what is in "$" is "thing" ? And if it's a comment why was the rest of the line not commented out like `] ) {` ? If it has other meanings, i will like to know. Sorry if my question sounds odd, i am just new to perl and perplexed by such an expression.