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.159 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.158 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.157 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.156 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.155 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.154 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.153 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.152 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.151 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.150 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.149 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.148 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.147 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.146 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.145 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.144 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.143 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.142 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.141 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm
trackler-2.2.1.140 tracks/perl5/exercises/pig-latin/.meta/solutions/PigLatin.pm