ACHTUNG
The following code is buggy, sorry.
... it will create empty files for each field ...
D:\tmp>type 1,George,CEO
1
George
CEO
D:\tmp>
strange behavior... (Update: see solution
here )
I didn't expect this, but Perl seems to silently refuse to re-open an already open file handle
so if you don't mind having the column head included you can go even shorter
D:\tmp>del id,name,position
D:\tmp>perl -lanE "open $FH[$x++], '>', $_ for @F;print $_ shift @F f
+or @FH" data.txt
D:\tmp>type id,name,position
id
id
1
2
3
name
name
Nick
George
Christina
position
position
boss
CEO
CTO
D:\tmp>
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.