foreach $sess(@sessions){ foreach(split(/\n/,$sess)){ if(/^.\d+/){ #ignore the formatting lines push @connections, [split]; #pushing a reference to the resulting array onto the array } } }