Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: Write a test to test the Anagram checker

  • Anagrams are words with the exact same letter, but in different order.
  • silent - listen
package MyAnagram;
use strict;
use warnings;

use Exporter qw(import);
our @EXPORT_OK = qw(is_anagram);

sub is_anagram {
    my ($x, $y) = @_;
    my $xx = join('', sort(split(//, $x)));
    my $yy = join('', sort(split(//, $y)));

    return $xx eq $yy;
}


1;