use IPC::System::Simple 'capturex'; my @cmd = ('cat','fake.txt'); chomp( my @lines = capturex @cmd ); shift @lines; # header my %data; for (@lines) { my ($coid,$type,$state,$id) = split; $data{$id}{CoID} = $coid; $data{$id}{State} = $state; } use Data::Dump; dd \%data; #### { 19425 => { CoID => "ExampleCo", State => "contact" }, 48541 => { CoID => "ExampleCo", State => "pending" }, 50123 => { CoID => "ExampleCo", State => "former" }, 60047 => { CoID => "ExampleCo", State => "contact" }, 75521 => { CoID => "ExampleCo", State => "ready" }, 97546 => { CoID => "ExampleCo", State => "former" }, }