arrays - Perl: Load data by row -


i'm continuing perl learning.

in case i'm trying load data .txt file array. script generates netstat output looks this:

proto recv-q send-q local address    foreign address         state       pid/program name tcp     0      0 0.0.0.0:3790        0.0.0.0:*               listen      7550/nginx.conf  tcp     0      0 127.0.1.1:53        0.0.0.0:*               listen      1271/dnsmasq     tcp     0      0 127.0.0.1:631       0.0.0.0:*               listen      24202/cupsd  

next step in process put data loaded file array , in hash, making sortable rows, example sorting output find out information belongs specific port number.

my question is: proper way load data array , hash make accessible , sortable output?

i think need aoh (array of hashes). after can want custom sort:

my @records = [  { proto => "tcp", 'recv-q' => 0, ..., 'local address' => "0.0.0.0:3790", ..., state => "listen", ... },  { proto => "tcp", 'recv-q' => 0, ..., 'local address' => "127.0.1.1:53", ..., state => "listen", ... },  { proto => "tcp", 'recv-q' => 0, ..., 'local address' => "127.0.0.1:631", ..., state => "listen", ... }, ];  @records_sorted_by_state = sort { $a->{state} cmp $b->{state} } @records;