DEV Community

loading...

Discussion on: Daily Challenge #1 - String Peeler

Collapse
jordonr profile image
Jordon Replogle

Perl?

$testing = "Happy coding!";
print &peeler($testing) . "\n";

sub peeler {
    my $str = shift;
    if(length($str) > 2) {
        return substr($str, 1, -1);
    }
}

Collapse
choroba profile image
E. Choroba

Or maybe just

sub peeler { shift =~ s/^.|.$//gr }
Forem Open with the Forem app