Hello, I am trying to sort strings taken in from a text file by the string's vowel sequence.
For example: Let vow1 be the substring of vowels appearing in str1, and vow2 the corresponding substring of str2. If the substring vow1 appears before vow2 in the ascending ASCII order,str1 appears before str2 in the output.
Here is what I have so far:
#!/usr/bin/perl -w use strict; my %hash; my @argv; my $file = $ARGV[0]; open (IN, $file) or die "Could not open file: $!"; while (my $line = <IN>) { my $vowels = my $w; $vowels =~ s/[^aeiou]//g; $hash {$vowels}{$w} = 1; } close(IN); foreach my $key (sort %hash) { foreach my $word (sort {$hash {$key}}) { print "$word\n"; } }
Example input would be: fanfare, apparate, panacea, parmesan, albatross, albacore, false, vermeil, candelabra, beans
The output should be: apparate fanfare panacea albatross albacore false parmesan candelabra beans vermeil
I am beyond stuck and any help would be appreciated.
In reply to Sorting Strings By Vowel Sequence by NewToPerl777
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |