open FH, 'file.name' or die "Cannot open 'file.name' for reading: $!\n"; my @items; while () { chomp; my @line = split; # Remove "#" and "STANDARD" shift @line; shift @line; # I assume the function name is the last item in the list and has no spaces in it my $function = pop @line; push @items, { function => $function, description => join( ' ', @line ), }; } close FH; foreach my $item (@items) { # $item->{description} is the description # $item->{function} is the function name } #### # If sorting ascending asciibetically. my @sorted_items = sort { $a->{description} cmp $b->{description} } @items;