use strict; use warnings; use YAML::Syck qw(DumpFile); my $dict_file = 'EN_AU.dic'; open my $dict, '<', $dict_file or die "Unable to open '$dict_file' for reading: $!"; my %word_table; while (<$dict>) { chomp $word; my $key = join '', sort map lc(), split //, $word; push @{$word_table{$key}}, $word; } DumpFile( 'dict.yml', \%word_table );