Notes: 1) @custinfo is where the data is returned from the command shown above 2) Not all data returned has a : in it, and we don't want that data so we just work on the data that is seperated by a ':' 3) In the case of the MACADDRESS there are spaces in front of it, so we delete them. foreach (@custinfo) { if($_=~/:/){ my ($key, $data) = split (/:/,$_); $key=~s/\s+//g; $record{$key} = $data; } }