Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Split tab-separated file into separate files, based on column name

by tybalt89 (Prior)
on Aug 26, 2020 at 13:29 UTC ( #11121100=note: print w/replies, xml ) Need Help??


in reply to Split tab-separated file into separate files, based on column name

#!/usr/bin/perl use strict; #https://perlmonks.org/?node_id=11121090 use warnings; my @handles = map { open my $fh, '>', "tmp.$_" or die; $fh } split /\t|\n/, <DATA>; while( <DATA> ) { my @data = split /\t|\n/; print { $handles[$_] } $data[$_], "\n" for 0 .. $#handles; } close $_ or die for @handles; __DATA__ id name position 1 Nick boss 2 George CEO 3 Christina CTO
  • Comment on Re: Split tab-separated file into separate files, based on column name
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11121100]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2020-10-24 04:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (242 votes). Check out past polls.

    Notices?