anthony brooke wrote:
> Hello, my logic is really bad, here is I want to do.
>
> my @list = qw(a b a a d e e );
>
> I want to compact the array by concatenating the adjacent vowels and
> consonant together, like for the above it should become,
>
> my @list2 = qw(ab aa d ee);
>
> How do I get the @list2 ? Thanks.
The program below appears to do what you need.
HTH,
Rob
use strict;
use warnings;
my @list = qw(a b a a d e e );
my @list2 = syllables(@list);
print "(@list2)\n";
sub syllables {
return @_ unless @_ > 1;
my @return;
foreach (@_) {
if ($return[-1] =~ /[^aeiou]$/) {
push @return, $_;
}
else {
$return[-1].= $_;
}
}
@return;
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/