in reply to Test for the last element in a foreach
There is nothing particularly elegant or fancy about this solution. In fact, it's down right boring. However, it's very clear what purpose each variable serves. And so is very maintainable.my @children = $category->children; for my $i (0..$#children) { my $subcat = $children[$i]; my $is_last = $i == $#children; # More code here. }
|
|---|