On the chatterbox, PhilHibbs asked Does anyone know how to make ls produce a comma-separated list, or have a perl one-liner to do it?

Here's a solution that does it all with command line switches:

ls -1|perl -054lp012e1
I leave it as an exercise to the reader to figure out how it works.

Replies are listed 'Best First'.
Re: Doing it with command line switches
by toolic (Bishop) on Dec 10, 2009 at 14:08 UTC
    Not nearly as obfu, and non-Perl, but fewer keystrokes :)
    ls -1|tr '\n' ,
      Even shorter:
      ls -mw 100000
      assuming that 100000 chars is enough.

      Note that tr \\n , is one character shorter than tr '\n' ,

      That's cheating, don't forget perl -e 'open X, ">foo\nbar";'
Re: Doing it with command line switches
by bv (Friar) on Dec 10, 2009 at 14:57 UTC
    perl -e '$,=",";print @ARGV' *

    @_=qw; Just another Perl hacker,; ;$_=q=print "@_"= and eval;
      perl -wle'$,=",";print<*>'

      Enjoy, Have FUN! H.Merijn
Re: Doing it with command line switches
by ambrus (Abbot) on Dec 11, 2009 at 11:32 UTC

    I think the  -1 is not needed. At least the gnu coreutils and the freebsd versions of ls default to using multi-column output only when the output goes to a terminal, and single-column output otherwise. In fact, even POSIX mandates that the single-column output is the default when the output is not to a terminal, and leaves the other case implementation-defined. (This is of course unless you alias ls to something stupid, which many people and even distributions do, but that's their fault, and in that case \ls is still shorter than ls -1.)