in reply to Bad Regex
my %comments; #comments keyed by line number open FH, "yourFile" or die $!; while (<FH>) { $comments{$.} = $_ if m/^#/ } close FH; [download]