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.180 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.179 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.178 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.177 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.176 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.175 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.174 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.173 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.172 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.171 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.170 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.169 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.167 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.166 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.165 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.164 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.163 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.162 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.161 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.160 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm