Sha256: 967436b45fde2d77e518046f54e2d38cc81e771af4f32f68157487c3604e4057

Contents?: true

Size: 712 Bytes

Versions: 49

Compression:

Stored size: 712 Bytes

Contents

package PigLatin;

use v5.10.1;
use strict;
use warnings;
no if $] >= 5.018, warnings => 'experimental';

sub translate {
    my $original = shift;
    my @pig_latin;

    foreach my $orig ( split /\s+/ => $original ) {
        given ($orig) {
            when (/^[aeiou]/)            { push @pig_latin => "${original}ay" }
            when (/^y[^aeiou]/)          { push @pig_latin => "${original}ay" }
            when (/^x[^aeiou]/)          { push @pig_latin => "${original}ay" }
            when (/^([^aeiou]*qu)(.+)/)  { push @pig_latin => "$2$1" . "ay"   }
            when (/^([^aeiou]+)(.+)/)    { push @pig_latin => "$2$1" . "ay"   }
        }
    }

    return join " " => @pig_latin;
}

__PACKAGE__;

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.138 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.137 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.136 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.135 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.134 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.133 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.132 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.131 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm