Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Rearranging columns in multiple text files

by igelkott (Curate)
on Mar 18, 2013 at 11:27 UTC ( #1024014=note: print w/replies, xml ) Need Help??


in reply to Rearranging columns in multiple text files

Nothing wrong with cut or calling unix commands in general but may as well use the normal Perl commands once you've started. In particular, look into split so for each file you could do something like:

@a = split(/\t/); print "$a[0]\t$a[1]\t$a[12]\t$a[11]\n";
There are fancier ways to do this but seems like it'd be best to keep it simple to begin with. The other parts depend on whether you are writing all results to a single file or operating on each file individually, etc.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024014]
help
Chatterbox?
LanX is Discipulus reciting "Springtime for Hitler" ?
[choroba]: erix could tell you how to do it in Postgres
[LanX]: NOOOOOOOOOOOOOOO not again
[chacham]: wow, mysql really is as bad as i thougt
[choroba]: completion?
[LanX]: That's what he usually does when MySQL is mentioned ;-)
[chacham]: the same thing could be achieved with a trigger
[LanX]: choroba yes
chacham shudders at the thought of using a trigger...so evil
LanX will need to find a Perl workaround ... :-|

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2017-03-30 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (360 votes). Check out past polls.