# Programmers - What method do you use to display comma seperated lists correctly?

**URL:** https://boards.straightdope.com/t/programmers-what-method-do-you-use-to-display-comma-seperated-lists-correctly/580603
**Category:** The Game Room
**Created:** [May 3, 2011, 7:06pm UTC](https://boards.straightdope.com/t/programmers-what-method-do-you-use-to-display-comma-seperated-lists-correctly/580603 "2011-05-03T19:06:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)
#### Post date: [May 3, 2011, 7:06pm UTC](https://boards.straightdope.com/t/programmers-what-method-do-you-use-to-display-comma-seperated-lists-correctly/580603/1 "2011-05-03T19:06:53Z")

</div>

arse-biscuit! I thought I’d posted this in GQ. Sorry. Going to repost it there.

---

<div class="post-metadata">

### Author: ![Terminus\_Est](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/terminus_est/32/3087_2.png) [@Terminus\_Est](https://boards.straightdope.com/u/Terminus_Est)
#### Post date: [May 3, 2011, 7:09pm UTC](https://boards.straightdope.com/t/programmers-what-method-do-you-use-to-display-comma-seperated-lists-correctly/580603/2 "2011-05-03T19:09:50Z")

</div>

I’d just use the built-in join function in Perl:

$str = join “,”, @list;

---

<div class="post-metadata">

### Author: ![Lobsang](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lobsang/32/4067_2.png) [@Lobsang](https://boards.straightdope.com/u/Lobsang)
#### Post date: [May 3, 2011, 7:15pm UTC](https://boards.straightdope.com/t/programmers-what-method-do-you-use-to-display-comma-seperated-lists-correctly/580603/3 "2011-05-03T19:15:05Z")

</div>

> [@Terminus\_Est](#):
>
> I’d just use the built-in join function in Perl:
> 
> $str = join “,”, @list;

replied in gq…

> **[Programmers - What method do you use to display comma seperated lists correctly?](https://boards.straightdope.com/sdmb/showthread.php?t=607097)**
>
> In other words, when you want to put commas in between the values, but not at the end of the list, you have to have slightly different behaviour for a single iteration of your list (ie - last item, neglect the comma) In PHP I’ve taken to doing it...

---

<div class="post-metadata">

### Author: ![fluiddruid](https://avatars.discourse-cdn.com/v4/letter/f/c2a13f/32.png) [@fluiddruid](https://boards.straightdope.com/u/fluiddruid)
#### Post date: [May 3, 2011, 7:39pm UTC](https://boards.straightdope.com/t/programmers-what-method-do-you-use-to-display-comma-seperated-lists-correctly/580603/4 "2011-05-03T19:39:41Z")

</div>

Closing due to new thread opened in GQ.
