bfdi533 has asked for the wisdom of the Perl Monks concerning the following question:
I am looking for a perl 1-liner to join a list of items from stdin to stdout joined with a comma. I have searched the monastary and cannot find anything on this.
Say my list looks like this and is in a file called 'file':
1 2 3 4 5 6 7 8 9 10
and I want it to look like this:
I have tried:1,2,3,4,5,6,7,8,9,10
cat file | perl -e "while (<>) { push @a; } ; print join(',',@a);"
This does not produce any output at all.
I must be missing something simple here.
Ed
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: perl 1-liner to join a list?
by merlyn (Sage) on Nov 11, 2003 at 21:16 UTC | |
by bfdi533 (Friar) on Nov 11, 2003 at 21:27 UTC | |
by Nkuvu (Priest) on Nov 11, 2003 at 21:34 UTC | |
by thens (Scribe) on Nov 12, 2003 at 12:46 UTC | |
by Smylers (Pilgrim) on Nov 12, 2003 at 16:04 UTC | |
by bfdi533 (Friar) on Nov 11, 2003 at 21:29 UTC | |
by Enlil (Parson) on Nov 11, 2003 at 21:48 UTC | |
by Nkuvu (Priest) on Nov 11, 2003 at 22:10 UTC | |
by kelan (Deacon) on Nov 11, 2003 at 22:26 UTC | |
| |
by Enlil (Parson) on Nov 12, 2003 at 00:02 UTC | |
by Roy Johnson (Monsignor) on Nov 12, 2003 at 16:35 UTC | |
Re: perl 1-liner to join a list?
by sauoq (Abbot) on Nov 11, 2003 at 21:27 UTC | |
Re: perl 1-liner to join a list?
by Roy Johnson (Monsignor) on Nov 11, 2003 at 21:39 UTC | |
Re: perl 1-liner to join a list?
by jmcnamara (Monsignor) on Nov 11, 2003 at 22:06 UTC | |
by sauoq (Abbot) on Nov 11, 2003 at 22:17 UTC | |
by Roy Johnson (Monsignor) on Nov 12, 2003 at 15:23 UTC | |
by thelenm (Vicar) on Nov 11, 2003 at 22:53 UTC | |
Re: perl 1-liner to join a list?
by diotalevi (Canon) on Nov 11, 2003 at 21:29 UTC | |
by sauoq (Abbot) on Nov 11, 2003 at 21:44 UTC | |
Re: perl 1-liner to join a list?
by dbameister (Initiate) on Nov 12, 2003 at 21:07 UTC |