in reply to ead a file which has three columns and store the content in a hash
use strict; use warnings; # node_id=11115481 use Text::CSV_XS qw( csv ); use List::MoreUtils qw(first_index true); my $aoa = csv(in=>'data.csv', sep_char=>"\t"); my $header = shift @$aoa; use constant REGULATION => first_index {/^Regulation$/} @$header; printf "Number of up is: %d\n" ."Number of down is: %d\n" ."Number of NA is: %d\n", map {count($_)} qw(up down NA); exit(0); sub count{ my $Regulation = $_[0]; local $_; return true {$_->[REGULATION] eq $Regulation } @$aoa; }
OUTPUT:
Number of up is: 9 Number of down is: 5 Number of NA is: 3
|
|---|