use strict; use warnings; my @list; open (FH, 'sample.txt') || die; while () { push @list, $1 if m/^(.+?):/; } print "@list";