in reply to Variant of map for special-casing the last item
{ my @list_in_html = map { "<li$_</li>" } @list; $list_in_html[-1] =~ s!<li>!<li class="last">!; } { my @list_in_html = map { "<li$_</li>" } @list[0.. @list - 2]; push @list_in_html, qq!<li class="last">$list[-1]</li>!; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Variant of map for special-casing the last item
by jdporter (Paladin) on Oct 25, 2010 at 15:19 UTC | |
by Anonymous Monk on Oct 25, 2010 at 15:29 UTC |