Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^5: Split tab-separated file into separate files, based on column name (open on demand)

by LanX (Saint)
on Aug 27, 2020 at 21:52 UTC ( [id://11121134]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Split tab-separated file into separate files, based on column name (open on demand)
in thread Split tab-separated file into separate files, based on column name

I think his point was that Awk has an open_on_demand.

And if you know Perl, well it's not very difficult to decipher this Awk script ...

( ... oh that's were Larry got these "ideas" from ;-)

My concern is that it's neither easier nor shorter than Perl.

For comparison here a script version of my one-liner - already w/o taking advantages of command-line switches.

$\="\n"; while (<DATA>) { @F = split; unless (@FH) { open $FH[@FH], ">", "$_.txt" for @F; } else { print $_ shift @F for @FH; } } __DATA__ id name position 1 Nick boss 2 George CEO 3 Christina CTO

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Re^5: Split tab-separated file into separate files, based on column name (open on demand)
  • Download Code

Replies are listed 'Best First'.
Re^6: Split tab-separated file into separate files, based on column name (open on demand)
by haukex (Archbishop) on Aug 28, 2020 at 13:56 UTC
    I think his point was that Awk has an open_on_demand.

    That's not what I quoted and was replying to, though. It's certainly an interesting feature of awk's to note, but going from there to saying that awk is better than Perl for the job is too much of a strech, IMHO. And, of course I was disappointed to see the "Best Nodes of The Day" list that node first.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found