Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: open input files once

by tybalt89 (Prior)
on Jul 14, 2020 at 19:11 UTC ( #11119315=note: print w/replies, xml ) Need Help??


in reply to open input files once

Works for any number of files...

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11119283 use warnings; @ARGV = <file*.tab>; # or just default from command line my $column = 0; my %key; while( <> ) { my @fields = split; $key{ join "\t", @fields[0 .. 3] }[$column] = $fields[6]; eof and ++$column; } for ( sort keys %key ) { print join( "\t", (split)[0 .. 2], '-', map $_ // 0, @{ $key{$_} }[ 0 .. $column - 1 ] ), "\n"; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2020-10-27 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (256 votes). Check out past polls.

    Notices?