use strict; use warnings; chomp( my @lines = do { local @ARGV = 'mongo.tab'; <> } ); my @headers = split /\t/, shift @lines; my @records = map [ split /\t/ ], @lines; 1; #### % perl -d munge.pl Loading DB routines from perl5db.pl version 1.23 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(munge.pl:4): chomp( my @lines = do { local @ARGV = 'mongo.tab'; <> } ); DB<1> #### DB<1> c 7 main::(munge.pl:7): 1; DB<2> #### DB<2> p scalar @records 16215 DB<3> p scalar @headers 118 DB<4> #### DB<4> $h{ $_ }++ for map $_->[ 0 ], @records DB<5> p scalar keys %h 16215 DB<6> #### DB<6> $h2{ $_ }++ for map $_->[ 1 ], @records DB<7> p scalar keys %h2 9027 #### DB<8> p ( sort { $h2{ $b } <=> $h2{ $a } } keys %h2 )[ 0 ] DB<9> #### DB<10> p $h2{''} 2904 DB<11> #### DB<12> p ( sort { $h2{ $b } <=> $h2{ $a } } keys %h2 )[ 1 ] "BBX " #### my $re = qr/ *\t */; my @headers = split /$re/, shift @lines; my @records = map [ split /$re/ ], @lines; #### DB<13> R Warning: some settings and command-line options may be lost! Loading DB routines from perl5db.pl version 1.23 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(munge.pl:4): chomp( my @lines = do { local @ARGV = 'mongo.tab'; <> } ); DB<12>