in reply to Variant of map for special-casing the last item

Hmm, tricky. It appears overly verbose and specific
{ 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

    Your solutions look more verbose, and considerably more error-prone.

    Anyway, sometimes you just really want to do everything in a single map.

      Your solutions look more verbose, and considerably more error-prone.

      How is less characters more verbose and "considerably" more error-prone?